This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] C undefined behavior fix
- From: kaih at khms dot westfalen dot de (Kai Henningsen)
- To: gcc at gcc dot gnu dot org
- Date: 05 Jan 2002 15:09:00 +0200
- Subject: Re: [PATCH] C undefined behavior fix
- Comment: Unsolicited commercial mail will incur an US$100 handling fee per received mail.
- Organization: Organisation? Me?! Are you kidding?
- References: <200201042203.g04M3FW08270@penguin.transmeta.com>
torvalds@transmeta.com (Linus Torvalds) wrote on 04.01.02 in <200201042203.g04M3FW08270@penguin.transmeta.com>:
> In article <20020104121403.D7262F3123@nile.gnat.com> you write:
> >
> >We can't avoid people writing wrong code, but we can avoid debate as to
> >whether the code is right or wrong :-)
>
> However, gcc clearly does the wrong thing with strcpy() right now.
>
> And the gcc people claim it is undefined behaviour, which is not
> actually true if you just add two casts (which won't actually change the
> low-level RTL at all). It is implementation-defined, and documented by
> gcc to do the bit-wise arithmetic that was exactly what the linker
> people expected.
What is most certainly undefined behaviour is running compiler output at
an address different from that the compiler assumed it was going to be run
at. You actually don't need any other argument :-)
> The gcc-3 optimization is _bogus_ as per the C standard, and has to be
> disabled at least for the case where the pointer was cast to an integer.
Well, the Liunux ppc kernel use is certainly also highly bogus as per the
C standard, and also - I will claim here - according to any reasonable
person.
MfG Kai