Skip to content
Snippets Groups Projects
Commit 72225ff2 authored by Jakub Jelinek's avatar Jakub Jelinek
Browse files

c++: Don't try to initialize zero width bitfields in zero initialization [PR109868]

My GCC 12 change to avoid removing zero-sized bitfields as they are
important for ABI and are needed for layout compatibility traits
apparently causes zero sized bitfields to be initialized in the IL,
which at least in 13+ results in ICEs in the ranger which is upset
about zero precision types.

I think we could even avoid initializing other unnamed bitfields, but
unfortunately !CONSTRUCTOR_NO_CLEARING doesn't mean in the middle-end
clearing of padding bits and until we have some new flag that represents
the request to clear padding bits, I think it is better to keep zeroing
non-zero sized unnamed bitfields.

In addition to skipping those fields, I have changed the logic how
UNION_TYPEs are handled, the current code was a little bit weird in that
e.g. if first non-static data member had error_mark_node type, we'd happily
zero initialize the second non-static data member, etc.

2023-05-17  Jakub Jelinek  <jakub@redhat.com>

	PR c++/109868
	* init.cc (build_zero_init_1): Don't initialize zero-width bitfields.
	For unions only initialize the first FIELD_DECL.

	* g++.dg/init/pr109868.C: New test.

(cherry picked from commit 78327cf0)
parent c2bfd2c3
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment