This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] C undefined behavior fix


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]