[13679] in Athena Bugs
RS/6000 xlc bug
daemon@ATHENA.MIT.EDU (John Carr)
Sat Jul 22 15:47:04 1995
To: bugs@MIT.EDU
Date: Sat, 22 Jul 1995 15:46:58 EDT
From: John Carr <jfc@MIT.EDU>
When an array index is written in the "backwards" form, index[pointer]
instead of pointer[index], xlc generates incorrect code. According to
the C standard array indexing is commutative and the order of arguments
should not matter.
This program, when compiled with xlc 1.2.1 or 1.3.0 with or without
optimization and with langlvl extended or ansi, produces incorrect
output.
#include <stdio.h>
main(int argc, char *argv[])
{
printf("%c(%x)\n", argc["012"], argc["012"]);
printf("%c(%x)\n","012"[argc], "012"[argc]);
return 0;
}
With xlc 1.3.0.38 I get this output when I run the program with no
arguments:
@(10000340)
1(31)
The second line is correct. The first line is wrong.
Please forward this report to IBM.