https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108993

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #3)
> (In reply to Pablo Anigstein from comment #2)
> > (In reply to Andrew Pinski from comment #1)
> > > Hmm,
> > >  I noticed that since GCC 7 with -std=c++17, the b.x is not initialized at
> > > all. So the question I have is there a difference between C++ standards 
> > > here?
> 
> Derived is an aggregate in C++17, so b{} does aggregate init, not value init.

And that means its Base subobject is copy-initialized from {} which means we
get a value-initialized object, so it's correct that b.x is not initialized in
C++17 (which is what is shown in your godbolt link, because you didn't specify
any -std option to override the -std=gnu++17 default).

With -std=c++14 it looks like b.x is always set to zero, if I'm reading the
assembly output correctly (but I'm probably not).

Reply via email to