https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96003

--- Comment #23 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #20)
> Martin, does the code in the packages follow the pattern below?
> 
> $ cat t.C && gcc -O2 -S -Wall t.C
> struct A { virtual ~A (); };
> struct B { virtual ~B (); void f (); };
> 
> void f (A *p)
> {
>   if (dynamic_cast<B*>(p))
>     dynamic_cast<B*>(p)->f ();
> }
> t.C: In function ‘void f(A*)’:
> t.C:7:29: warning: ‘this’ pointer is null [-Wnonnull]
>     7 |     dynamic_cast<B*>(p)->f ();
>       |                             ^
> t.C:2:32: note: in a call to non-static member function ‘void B::f()’
>     2 | struct B { virtual ~B (); void f (); };
>       |                                ^

I guess so, looking at the libyui-ncurses-pkg issue:

class YWidget {...}

class NCWidget : public tnode<NCWidget*>, protected NCursesError {...}

wrect NCPackageSelector::deleteReplacePoint()
{
    // delete current child of the ReplacePoint
    YWidget * replaceChild = replacePoint->firstChild();
    wrect oldSize;

    if ( replaceChild )
    {
        oldSize = dynamic_cast<NCWidget *>(replaceChild)->wGetSize();
...

That seems to me like a bug as NCWidget is not the base of YWidget.
Am I right?

Reply via email to