https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115435
Bug ID: 115435 Summary: Issue warning for indirect call to pure virtual function in ctor or dtor Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Blocks: 87403 Target Milestone: --- We warn about undefined calls to pure virtual functions from constructors and destructors: struct Base { virtual void f() = 0; Base() { f(); } }; <source>: In constructor 'Base::Base()': <source>:3:15: warning: pure virtual 'virtual void Base::f()' called from constructor 3 | Base() { f(); } | ~^~ But for indirect calls we don't warn: struct Base { virtual void f() = 0; Base() { g(); } void g() { f(); } }; It would be good if IPA could warn for this case too. After g() is inlined into the constructor we know that the call to f() is undefined. I assume this would mean moving the warning from the front end to the middle end. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87403 [Bug 87403] [Meta-bug] Issues that suggest a new warning