https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122962
Bug ID: 122962
Summary: UBSAN false positive calling non virtual member of
virtual base during construction
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: nilsgladitz at gmail dot com
Target Milestone: ---
Might be related to e.g. PR117976; my initial case had multiple inheritance too
but this seems to reproduce without:
struct Base
{
Base(int something = 0)
{
}
virtual ~Base() = default;
} ;
struct Derived: Base
{
Derived( ):
Base( foo() )
{
}
int foo()
{
return 0;
}
} ;
int main()
{
Derived derived;
}
Unless I am missing something I think this is valid but UBSan with e.g. gcc
15.2 notes (https://godbolt.org/z/95fKPnWvY):
/app/example.cpp:14:12: runtime error: member call on address 0x7ffcbaa07ec8
which does not point to an object of type 'Derived'
0x7ffcbaa07ec8: note: object has invalid vptr
00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 90 9d c2 15 ce
7e 00 00 00 00 00 00
^~~~~~~~~~~~~~~~~~~~~~~
invalid vptr