You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
compiled with UBSAN. We get the following warning:
ubsan-test.cpp:16:15: runtime error: downcast of address 0x7ffc23c64be0 which does not point to an object of type 'C'
0x7ffc23c64be0: note: object is of type 'EnableA<C>'
00 00 00 00 90 30 40 00 00 00 00 00 70 30 40 00 00 00 00 00 01 00 00 00 00 00 00 00 90 95 c2 51
^~~~~~~~~~~~~~~~~~~~~~~
vptr for 'EnableA<C>'
The static_cast gets flagged as an invalid down-cast, since this has not finished construction. But we are not accessing the Derived object at all, only using it to access the already initialized A class (internally this is static_cast<A*>(static_cast<C*>(this))->foo();)
There has also been a similar discussion on StackOverflow, which sounds like the specification is unclear here, but since we are not calling any virtual functions or using any RTTI, it is not immediately clear why the standard should be interpreted so strictly here.
Take the following piece of code
compiled with UBSAN. We get the following warning:
The
static_cast
gets flagged as an invalid down-cast, sincethis
has not finished construction. But we are not accessing theDerived
object at all, only using it to access the already initializedA
class (internally this isstatic_cast<A*>(static_cast<C*>(this))->foo();
)There has also been a similar discussion on StackOverflow, which sounds like the specification is unclear here, but since we are not calling any virtual functions or using any RTTI, it is not immediately clear why the standard should be interpreted so strictly here.
Related issue: ginkgo-project/ginkgo#1655
The text was updated successfully, but these errors were encountered: