c++: Reject union std::initializer_list [PR102434]
authorMarek Polacek <polacek@redhat.com>
Sat, 29 Jan 2022 01:01:06 +0000 (20:01 -0500)
committerMarek Polacek <polacek@redhat.com>
Mon, 31 Jan 2022 20:35:20 +0000 (15:35 -0500)
commitb1a8b92f8f78536a00012e2e53a0d12ddbe6836d
tree6e77bd1248ff2e15ab1eff05612a55a457b240a3
parent76dc465aaf1b74bf92143510b6db5671e1c053d6
c++: Reject union std::initializer_list [PR102434]

Weird things are going to happen if you define your std::initializer_list
as a union.  In this case, we crash in output_constructor_regular_field.

Let's not allow such a definition in the first place.

PR c++/102434

gcc/cp/ChangeLog:

* class.cc (finish_struct): Don't allow union initializer_list.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/initlist128.C: New test.
gcc/cp/class.cc
gcc/testsuite/g++.dg/cpp0x/initlist128.C [new file with mode: 0644]