This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] C undefined behavior fix
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: David Woodhouse <dwmw2 at infradead dot org>
- Cc: "Petr Vandrovec" <VANDROVE at vc dot cvut dot cz>, Paul Koning <pkoning at equallogic dot com>, trini at kernel dot crashing dot org, 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
- Date: 03 Jan 2002 16:44:14 -0200
- Subject: Re: [PATCH] C undefined behavior fix
- Organization: GCC Team, Red Hat
- References: <DC4407B5751@vcnet.vc.cvut.cz> <21991.1010010254@redhat.com>
On Jan 2, 2002, David Woodhouse <dwmw2@infradead.org> wrote:
> VANDROVE@vc.cvut.cz said:
>> (and for CONSTANT < 5 it of course generated correct code to fill dst
>> with string contents; and yes, I know that code will sigsegv on run
>> because of dst is not initialized - but it should die at runtime, not
>> at compile time).
> An ICE, while it's not quite what was expected and it'll probably get fixed,
> is nonetheless a perfectly valid implementation of 'undefined behaviour'.
Not really. Think of code whose execution is guarded by a test that
guarantees it won't invoke undefined behavior, but whose test is in a
separate translation unit. Or even of code that is never executed.
The compiler has no business telling whether the code may potentially
invoke undefined behavior, or whether it's going to be executed at
all, it has to compile it to something that does whatever it wishes
*if* it's executed. So, it should indeed die at runtime, not at
compile time.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me