This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] C undefined behavior fix
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: Tom Rini <trini at kernel dot crashing dot org>
- Cc: Momchil Velikov <velco at fadata dot bg>, linux-kernel at vger dot kernel dot org, gcc at gcc dot gnu dot org, linuxppc-dev at lists dot linuxppc dot org, Franz Sirl <Franz dot Sirl-kernel at lauterbach dot com>, Paul Mackerras <paulus at samba dot org>, Benjamin Herrenschmidt <benh at kernel dot crashing dot org>, Corey Minyard <minyard at acm dot org>
- Date: Fri, 04 Jan 2002 09:42:55 +0100
- Subject: Re: [PATCH] C undefined behavior fix
- References: <87g05py8qq.fsf@fadata.bg><20020102190910.GG1803@cpe-24-221-152-185.az.sprintbbd.net>
Tom Rini <trini@kernel.crashing.org> writes:
> 1) Change this particular strcpy to a memcpy
That doesn't fix the undefined behavior.
> 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?)
That doesn't fix the undefined behavior.
> 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)
That *does* fix the undefined behavior, and it seems that GCC is going
to stay the same in the future, so this is a feasible workaround.
> 4) Introduce a function to do the calculations [2]. (Corey Minyard)
That doesn't fix the undefined behavior.
> 5) 'Properly' set things up so that we don't need the RELOC() macros
> (-mrelocatable or so?), and forget this mess altogether.
This is the clean approach, and thus preferable in the long term. (3)
seems to be the best short-time solution.