]> 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>
Thu, 22 Apr 2021 14:30:31 +0000 (16:30 +0200)
commit3a51e6261f7d98d54fc370125b1895542c3cdce9
tree7617ba8254889c999b6ae7a09bf2144c413776c1
parent83b2007abb2ad05209483e8b9f75aec9b385bbb9
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 af868e89ec21340d1cafd26eaed356ce4b0104c3)
gcc/cp/init.c
gcc/testsuite/g++.dg/ubsan/pr99106.C [new file with mode: 0644]