]> gcc.gnu.org Git - gcc.git/commit
varasm: Fix output_constructor where a RANGE_EXPR index needs to skip some elts ...
authorJakub Jelinek <jakub@redhat.com>
Tue, 7 Apr 2020 18:59:37 +0000 (20:59 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 17 Sep 2020 15:40:58 +0000 (17:40 +0200)
commit042d9c31cb79d7706b49039e8ba92b85a398629d
tree0c342ac69877394cacc889e77b6e575ba118e157
parente0f892394dbd59b411ba72113166e2396a77f563
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.

(cherry picked from commit 56407bab53a514ffcd6ac011965cebdc5eb3ef54)
gcc/testsuite/g++.dg/torture/pr94303.C [new file with mode: 0644]
gcc/varasm.c
This page took 0.066976 seconds and 6 git commands to generate.