This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
diagnostic request
- From: phr-2002 at nightsong dot com
- To: bug-gcc at gnu dot org
- Date: 6 Feb 2002 11:18:54 -0000
- Subject: diagnostic request
- Reply-to: phr-2002 at nightsong dot com
The code
int a[3] = {1, 2, 3};
test() { a[a[0]]=1; }
looks like it sets a[1] to 1. However, according to some intricate
reading of the ANSI C standard, its behavior is apparently undefined--
there's no sequence point after the computation of a[0]. Apparently
this is intended to allow vectorizing compilers to optimize array
assignments by assuming the arrays aren't "self-modifying". I don't
understand the subtleties and may have gotten the example slightly
wrong, but there's a big thread about it in comp.std.c right now,
that's spilled over into sci.crypt.
I think GCC should compile the above code in whatever way it wants,
but it should print a diagnostic warning of a possible bug.