Re: [PATCH] C undefined behavior fix

Tom Rini
2002-01-02T23:55:24Z

On Thu, Jan 03, 2002 at 01:28:42AM +0200, Momchil Velikov wrote:
> >>>>> "Paul" == Paul Mackerras <paulus@samba.org> writes:
>
> Paul> Tom Rini writes:
>
> >> Okay, here's a summary of all of the options we have:
> >> 1) Change this particular strcpy to a memcpy
> >> 2) Add -ffreestanding to the CFLAGS of arch/ppc/kernel/prom.o (If this
> >> optimization comes back on with this flag later on, it would be a
> >> compiler bug, yes?)
> >> 3) Modify the RELOC() marco in such a way that GCC won't attempt to
> >> optimize anything which touches it [1]. (Franz, again by Jakub)
> >> 4) Introduce a function to do the calculations [2]. (Corey Minyard)
> >> 5) 'Properly' set things up so that we don't need the RELOC() macros
> >> (-mrelocatable or so?), and forget this mess altogether.
>
> Paul> I would add:
>
> Paul> 6) change strcpy to string_copy so gcc doesn't think it knows what the
> Paul> function does
>
> GCC thinks exactly what the function does.

And then optimizes it to something that fails to work in this particular
case.

--
Tom Rini (TR1265)