]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Fix up build_zero_init_1 once more [PR99106]
authorJakub Jelinek <jakub@redhat.com>
Wed, 17 Feb 2021 14:03:25 +0000 (15:03 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 19 Mar 2021 23:27:49 +0000 (00:27 +0100)
commitaf868e89ec21340d1cafd26eaed356ce4b0104c3
treeb11fe9620699d6b0eb2a7d514bcd1864e797a280
parent45de8afb2d534e3b38b4d1898686b20c29cc6a94
c++: Fix up build_zero_init_1 once more [PR99106]

My earlier build_zero_init_1 patch for flexible array members created
an empty CONSTRUCTOR.  As the following testcase shows, that doesn't work
very well because the middle-end doesn't expect CONSTRUCTOR elements with
incomplete type (that the empty CONSTRUCTOR at the end of outer CONSTRUCTOR
had).

The following patch just doesn't add any CONSTRUCTOR for the flexible array
members, it doesn't seem to be needed.

2021-02-17  Jakub Jelinek  <jakub@redhat.com>

PR sanitizer/99106
* init.c (build_zero_init_1): For flexible array members just return
NULL_TREE instead of returning empty CONSTRUCTOR with non-complete
ARRAY_TYPE.

* g++.dg/ubsan/pr99106.C: New test.

(cherry picked from commit 7768cadb4246117964a9ba159740da3b9c20811d)
gcc/cp/init.c
gcc/testsuite/g++.dg/ubsan/pr99106.C [new file with mode: 0644]