This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/70035] [5/6 Regression] Calling a non-virtual member in base-class constructor call with ubsan causes segfault when superclass has virtual member with same name
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 02 Mar 2016 17:25:47 +0000
- Subject: [Bug c++/70035] [5/6 Regression] Calling a non-virtual member in base-class constructor call with ubsan causes segfault when superclass has virtual member with same name
- Auto-submitted: auto-generated
- References: <bug-70035-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70035
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The call to a member function before all base classes are initialized is
undefined behaviour:
12.6.2 [class.base.init] p16
Member functions (including virtual member functions, 10.3) can be called for
an object under construction.[...] However, if these operations are performed
in a ctor-initializer (or in a function called directly or indirectly from a
ctor-initializer) before all the mem-initializers for base classes have
completed, the result of the operation is undefined.
There is a very similar example below that paragraph.