This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

diagnostic request


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]