Description of Problem: The attached testcase produces wrong output when compiled with -O2 Version-Release number of selected component (if applicable): 2.96-110 How Reproducible: Every time Steps to Reproduce: 1. Compile test.c with -O2 2. run 3. Actual Results: [kmaraas@sevilla kmaraas]$ ./test should be '/Documents': /Documents should be 'Documents': Documents should be 'Documents': /Documents should be 'Documents': Documents Expected Results: Correct output Additional Information: Also get the same results with gcc3 (gcc3-3.0.4-1)
No testcase attached...
Created attachment 58266 [details] test case for compiler bug
Sorry about that :) Should be there now
Any news on this? Would be nice to know if it actually is a bug in the compiler or not. Sorry to be nagging about it, but I suddenly stopped trusting my compiler after seeing this :)
I've made a self contained testcase from it (bellow), verified the bug in 2.96-RH and 3.0.x and found it is works just fine in 3.1. As it works in 3.1, it is lower priority to me ATM. typedef struct { char *str; int len; } A; A *foo (void) { static A x; x.str = "1234"; x.len = 5; return &x; } int bar (const char *x) { } char *baz (const char *x) { return (char *) x; } int main (int argc, char *argv[]) { char *s, *t; A *u; u = foo (); t = (*u->str == '\0') ? u->str : (u->str + 1); s = baz ((*u->str == '\0') ? u->str : (u->str + 1)); bar (s); bar (t); if (*s != '2') abort (); return 0; }
I had someone test it on 3.1 sparc and he saw the problem there too. I'll try to get the version from him.
He used 3.1.0 from sunfreeware. Self compiled.
Close this as fixed in the latest release?
Confirmed ok in 8.0