Re: [PATCH] C undefined behavior fix

From: Momchil Velikov (
Date: Wed Jan 02 2002 - 06:40:06 EST

>>>>> "Aaron" == Aaron Lehmann <> writes:

Aaron> On Wed, Jan 02, 2002 at 01:03:25AM +0200, Momchil Velikov wrote:
>> Thus
>> strcpy (dst, "abcdef" + 2)
>> gives
>> memcpy (dst, "abcdef" + 2, 5)

Aaron> IMHO gcc should not be touching these function calls, as they are not
Aaron> made to a standard C library, and thus have different behaviors. I'm
Aaron> suprised that gcc tries to optimize calls to these functions just
Aaron> based on their names.

IIRC, these identifiers are reserved by the C standard, thus the
compiler is right to assume that they have standard behavior. And note
that they DO have the standard behavior. It even doesn't matter if GCC
is right to judge by the names in each and every case, it is right
in _this_ case.

Aaron> The gcc manpage mentions

Aaron> -ffreestanding
Aaron> Assert that compilation takes place in a freestanding
Aaron> environment. This implies -fno-builtin. A freestand­
Aaron> ing environment is one in which the standard library
Aaron> may not exist, and program startup may not necessarily
Aaron> be at "main". The most obvious example is an OS ker­
Aaron> nel. This is equivalent to -fno-hosted.

Aaron> Why is Linux not using this? It sounds very appropriate. The only

Because it results in less optimization. I see no point in
deliberately preventing the compiler from doing optimizations.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Mon Jan 07 2002 - 21:00:17 EST