[Bug c++/52377] C++11 non-static initializers in unions are not used

2017-12-13 Thread dmitry.v.rogozhkin at intel dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52377

dmitry.v.rogozhkin at intel dot com changed:

   What|Removed |Added

 CC||dmitry.v.rogozhkin at intel 
dot co
   ||m

--- Comment #5 from dmitry.v.rogozhkin at intel dot com ---
May I have additional information on this bug, please:
1. What was the patch which fixed the bug?
2. The noted behavior to have 0 values for union members with -O: is that
permanent behavior or we can randomly get non-zero values
3. Was the fix backported to 4.8, if not - why?

[Bug c++/52377] C++11 non-static initializers in unions are not used

2017-12-13 Thread dmitry.v.rogozhkin at intel dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52377

--- Comment #7 from dmitry.v.rogozhkin at intel dot com ---
>> 2. The noted behavior to have 0 values for union members with -O: is that
>> permanent behavior or we can randomly get non-zero values
>If the member is initialized, we should get the correct value.  Otherwise it's 
>undefined behavior.

We get correct value which we tried to initialize on 4.9. But on 4.8 we don't
and there are 2 cases: 1) if we compiled without -O we get random values, 2) if
we compiled with -O, -O1/2/3 we get 0 while we tried to initialize to something
else (to 4 in the example from bug description). I thought that the code change
will shine the light on that, but unfortunately it does not, at least for me.
So, I am trying to understand whether initialization to 0 on 4.8  compiler
under -O option is a permanent behavior or we still may randomly get something
else?