-Wglobal-constructors is silenced for derived classes with a virtual base destructor in c++2b mode #121004
Labels
c++23
clang:diagnostics
New/improved warning or error message in Clang, but not in clang-tidy or static analyzer
When a class that contains a non trivial member inherits from a pure virtual base class that has an explicitly declared virtual destructor in c++2b mode -Wglobal-constructors is not raised, but an entry is still added to the .init_array to initialize the objects vtable before main. This behaviour is not present in c++20 mode. The entry is only added at -O0, at -O2 and higher
__cxx_global_var_init
is elided and the vtable is placed directly in the data section which makes this very hard to track down.Godbolt reproducer link: https://godbolt.org/z/W355314dK
The text was updated successfully, but these errors were encountered: