[873] in SIPB_Linux_Development
[FWD] Linus Torvalds: Re: gcc bug
daemon@ATHENA.MIT.EDU (Erik Nygren)
Sat Dec 31 00:24:15 1994
To: linux-dev@MIT.EDU, sipb@MIT.EDU
Date: Sat, 31 Dec 1994 00:23:45 -0500
From: Erik Nygren <nygren@MIT.EDU>
Thought people might find this interesting...
I see this under gcc 2.5.8 under Linux.
---- Erik
------- Forwarded Message
Date: Thu, 29 Dec 1994 19:49:45 +0200
From: Linus Torvalds <Linus.Torvalds@cs.helsinki.fi>
Message-Id: <199412291749.TAA11855@keos.Helsinki.FI>
In-Reply-To: Andries.Brouwer@cwi.nl's message as of Dec 29, 17:10
X-Mailer: Mail User's Shell (7.2.0 10/31/90)
To: Andries.Brouwer@cwi.nl, linux-kernel@vger.rutgers.edu
Subject: Re: gcc
Sender: owner-linux-kernel@vger.rutgers.edu
Precedence: bulk
Andries.Brouwer@cwi.nl: "gcc" (Dec 29, 17:10):
>
> You write: gcc does not translate ?: correctly.
> Can you be slightly more precise (and answer on the kernel
> channel - no doubt others want to know this as well)?
> The kernel is full of ?: constructions. Are all of these
> potential bugs? Or is it inline functions only? What version of gcc?
> [I have not yet encountered a bug in 2.5.8.]
The ?:-bug in gcc isn't exactly easy to see (and believe me: it wasn't
easy to find, especially when I didn't expect a compiler bug). Simple
test-case (I reported this on gnu.gcc.bug already):
- ----------
#include <stdio.h>
static short limit(unsigned short v, unsigned short u)
{
return ((v > u) ? u : v);
}
static short limit2(unsigned short v, unsigned short u)
{
if (v > u)
return u;
return v;
}
#define t(x,y) printf("%d (%d)\n", limit(x,y), limit2(x,y));
int main(int argc, char **argv)
{
t(-1,2);
t(5,6);
t(7,-2);
}
- ----------
limit() and limit2() should give the same result, but they actually
don't..
Linus
------- End of Forwarded Message