[Bug c++/89481] constexpr function allows writing one active union member and reading another
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Feb 25 09:29:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89481
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2019-02-25
CC| |jakub at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC trunk starting with r269052 aka PR89336 fix will reject this too for
-std=c++14 and -std=c++17 too:
pr89481.C:20:29: in ‘constexpr’ expansion of ‘all_zeros()’
pr89481.C:10:32: error: change of the active member of a union from
‘all_zeros()::mix::numeric’ to ‘all_zeros()::mix::bytes’
10 | zero.bytes[sizeof(double)] = '\0';
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
It is accepted with -std=c++2a where changing of active member is allowed.
More information about the Gcc-bugs
mailing list