This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] C undefined behavior fix
- From: Linus Torvalds <torvalds at transmeta dot com>
- To: alan at lxorguk dot ukuu dot org dot uk, gcc at gcc dot gnu dot org
- Cc:
- Date: Fri, 4 Jan 2002 13:53:41 -0800
- Subject: Re: [PATCH] C undefined behavior fix
- Newsgroups: linux.egcs
- Organization:
- References: <20020103000118.GR1803@cpe-24-221-152-185.az.sprintbbd.net>
In article <E16Lvh8-0006E6-00@the-village.bc.nu> you write:
>> Yes, but doesn't -ffreestanding imply that gcc _can't_ assume this is
>> the standard library, and that strcpy _might_ not be what it thinks, and
>> to just call strpy?
>
>strcpy is part of the C standard. You'd need a -fits-not-c-its-linux
No. strcpy() is part of the C standard, yes, but so are a lot of other
things, including the rules on arithmetic and pointer conversion. The
current gcc strcpy() optimization is clearly illegal if it doesn't allow
for those other C rules.
While the expression
"string" - TASK_BASE
may be undefined, the expression
(void *)((unsigned long)"string" - TASK_BASE)
is _not_ undefined, and gcc cannot play it's illegal games with it.
Linus