[Bug middle-end/94303] [8/9 Regression] Program result error When using global object array (partially initialized with a special constructor, and the rest with the default constructor)
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Apr 7 19:04:12 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94303
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:56407bab53a514ffcd6ac011965cebdc5eb3ef54
commit r9-8471-g56407bab53a514ffcd6ac011965cebdc5eb3ef54
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Apr 7 20:59:37 2020 +0200
varasm: Fix output_constructor where a RANGE_EXPR index needs to skip some
elts [PR94303]
The following testcase is miscompiled, because output_constructor doesn't
output the initializer correctly. The FE creates {[1...2] = 9} in this
case, and we emit .long 9; long 9; .zero 8 instead of the expected
.zero 8; .long 9; .long 9. If the CONSTRUCTOR is {[1] = 9, [2] = 9},
output_constructor_regular_field has code to notice that the current
location (local->total_bytes) is smaller than the location we want to write
to (1*sizeof(elt)) and will call assemble_zeros to skip those. But
RANGE_EXPRs are handled by a different function which didn't do this,
so for RANGE_EXPRs we emitted them properly only if local->total_bytes
was always equal to the location where the RANGE_EXPR needs to start.
2020-03-25 Jakub Jelinek <jakub@redhat.com>
PR middle-end/94303
* varasm.c (output_constructor_array_range): If local->index
RANGE_EXPR doesn't start at the current location in the
constructor,
skip needed number of bytes using assemble_zeros or assert we don't
go backwards.
PR middle-end/94303
* g++.dg/torture/pr94303.C: New test.
More information about the Gcc-bugs
mailing list