https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124834
Bug ID: 124834
Summary: Devirtualization should not attempt to call pure
virtual functions
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: luigighiron at gmail dot com
Target Milestone: ---
GCC attempts to do devirtualization in the following program:
struct A{
virtual void foo()=0;
A(){
foo();
}
};
struct B:A{
void foo(){}
};
void bar(){
B();
}
int main(){}
Which causes a linker error since it is attempting to call A::foo but there is
no definition of A::foo. This is not an odr-use of A::foo though, so it should
not be invalid. Note that the call to foo is never actually reached, so the
undefined behavior does not happen. Clang does not seem to have this issue, but
MSVC does.