From: Mark Mitchell Date: Sun, 1 Jul 2001 20:50:03 +0000 (+0000) Subject: expr.c (expand_expr, [...]): Correct check for side-effects in the value of an array... X-Git-Tag: prereleases/libstdc++-3.0.95~3538 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c54b0a5e4b261487b58d4ec2db7219f8f5c7233d;p=thirdparty%2Fgcc.git expr.c (expand_expr, [...]): Correct check for side-effects in the value of an array element. * expr.c (expand_expr, case ARRAY_REF): Correct check for side-effects in the value of an array element. From-SVN: r43680 --- diff --git a/gcc/expr.c b/gcc/expr.c index c5276f2556ec..afa55a687083 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -6902,7 +6902,7 @@ expand_expr (exp, target, tmode, modifier) elem = TREE_CHAIN (elem)) ; - if (elem && !TREE_SIDE_EFFECTS (elem)) + if (elem && !TREE_SIDE_EFFECTS (TREE_VALUE (elem))) return expand_expr (fold (TREE_VALUE (elem)), target, tmode, ro_modifier); } diff --git a/gcc/testsuite/g++.old-deja/g++.other/array6.C b/gcc/testsuite/g++.old-deja/g++.other/array6.C new file mode 100644 index 000000000000..ab076f2af383 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/array6.C @@ -0,0 +1,20 @@ +// Special g++ Options: -O1 + +int count = 0; + +double foo () { + count++; + return 0; +}; + +double bar () { + const double x[1] = { foo() }; + return x[0]; +}; + +int main () +{ + bar(); + if (count != 1) + return 1; +};