This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]