This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Storage for uninitialized objects (PR 24626)
- From: Steven Bosscher <steven dot bosscher at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Cc: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>, Robert Dewar <dewar at adacore dot com>, schlie at comcast dot net, ian at airs dot com, jsm28 at gcc dot gnu dot org
- Date: Sun, 15 Jan 2006 22:24:50 +0100
- Subject: Re: Storage for uninitialized objects (PR 24626)
- References: <200601152113.k0FLDsmm002972@hiauly1.hia.nrc.ca>
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.
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.
Gr.
Steven