<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/121004>121004</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
-Wglobal-constructors is silenced for derived classes with a virtual base destructor in c++2b mode
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
apache-hb
</td>
</tr>
</table>
<pre>
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
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8kz-P8zYMxj-NvBAJbNlOLoOHXIt06NClwI0BJTERe7JkSLJzeT99ISfXuxboO_kPyYc_Uo8wJb56okH0r6L_tcI52xAHnFBb2lhVqWDuw5slDwjaYUqQLWbQwWdknwDBBw858sLoYKRRUQT2liLnBJcYRkCY5kiwcMwzOlCY6LuUxQTogT4mx5qzu4Mh7TCS-afEUMpx1jkUadBCvgr5KhWMwRBs3q4uKHQbHfxnWgJO4EOGiJzICPkLqDmvbXyO9xJNmZ0DNIYM5ADZEmzZcz5jjHgvv8oXo-MftEaD-ot0TrBkVI5A0SVEghHZb-FPywkUWVw4zPGz-RQpkc_fmeuVuRTQF0rw7v4kwQybP-rCu75JQG_A8tVSBLGrz2f98XF-zHteMJ4Lo9jVRYUcrwrerLhPTE4wOdRkwHAkXdbLfk0wmBES6czBw82ytjDiO5VT4QQLxTtYjI_lRNTvYMLNb0V9FPXxt2BUcBkiTTGYWVMEx_5dtEewOU9JtEchT0Kero_EbYhXIU8_hDy9tX3fNp35vTJDaw7tASsamn3bHQ512_WVHV463e4V7br2RSrT97o3Gvdt3zY70i9GVTzIWnaNlK1sur7rt-pwITJ7vPSXRu77WnQ1jchu69wylt4VpzTT0MimrrvKoSKXVstL6ekGa1RIWW5AHErRRs3XJLraccrpSyZzdjT8r-MSO_Jl15cQwVDkhczD6pTgxtkC_vsa_MzY1Rzd8J9tcraz2uowCnkqUM_HZoqhmFPI0zpKEvL0nHUZ5N8BAAD__13uVSI">