https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70035
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org,
| |jason at gcc dot gnu.org
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #3)
> 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.
Is there any reason why the compiler couldn't warn in this case at compile
time?
At least for the non-virtual calls like this? It should know that the call is
in the mem-initializer for a base class and thus clearly it is not completed
yet.