[Bug c++/96003] [11 Regression] spurious -Wnonnull calling a member on the result of static_cast

marxin at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Feb 8 09:40:09 GMT 2021


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

--- Comment #19 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #17)
> Warnings for the static cast suppressed in r11-2457.
> 
> The warning for the dynamic cast is still issued and I would suggest to use
> a cast to a reference instead, both to avoid it and as an indication that
> the cast is expected to succeed (or throw):
> 
>      if (mainloop_ && typeid(mainloop_) == typeid(M)) {
>           dynamic_cast<M&>(*mainloop_).setup_M( );

I still see quite some packages failing due to the warning in the dynamic_cast
context. Can you please write a note into Porting to section?


More information about the Gcc-bugs mailing list