Steven Bosscher wrote:
On Sunday 15 January 2006 22:13, John David Anglin wrote:#include <stdio.h> unsigned char T (unsigned char x) { static int first = 1; static unsigned char firstx;if (first) { first = 0; firstx = x; return ~x; } if (x == firstx) printf ("Behavior is pre GCC 4.0\n"); else printf ("Behavior is GCC 4.0 and later\n"); return 0; }So firstx can have an indeterminate value coming into "if (x == firstx)" and the behavior is still undefined.
Right that's my understanding of the standard
For what it's worth, it annoys me to no end that you have managed to turn more than a day of hard work to understand and fix PR24626 into a discussion about defining undefined behavior. I don't think I'll ever look at HPPA bugs anymore if they don't affect me.
Well we have to understand whether something is a bug before we go off "fixing" it. We often find that reported optimization bugs are in fact just manifestations of bugs in the program, and indeed it can often be complex to figure this out. We really really ought to have a switch to initialize everything by default, then you can tell immediately if something like this is due to uninitialized variables. However, an interesting issue is whether this behavior is valid for Ada, I don't think it is (the Ada standard is much stricter about the effect of uninitialized variables). But it may still be OK, needs careful analysis.
Gr. Steven
