https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109568
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Why do you think the warning is incorrect in this case? The warning is about dynamic_cast<Derived*>(var); which can return nullptr if var doesn't point to Derived object or something derived from it. In that case, var_ref->empty() will invoke the empty method on nullptr, which is invalid.