This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/48814] [4.4/4.5/4.6/4.7 Regression] Incorrect scalar increment result
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 09 Feb 2012 13:03:25 +0000
- Subject: [Bug middle-end/48814] [4.4/4.5/4.6/4.7 Regression] Incorrect scalar increment result
- Auto-submitted: auto-generated
- References: <bug-48814-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48814
--- Comment #10 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-02-09 13:03:25 UTC ---
For
extern void abort (void);
struct S { int i; };
struct S arr[32];
volatile int count = 0;
struct S __attribute__((noinline))
incr (void)
{
++count;
}
int main()
{
arr[count++] = incr ();
if (count != 2)
abort ();
return 0;
}
we can only avoid reading 'count' too many times (once to get at the
index for the store and once for updating its value) if we can
insert a statement inbetween the call and the store to arr[]. Which
we can do only if we are introducing an aggregate temporary - which
might work in C, but does not work in C++ when we require
return-slot-optimization. Thus, in the face of volatiles and required RSO
this is unfixable.