Date: Sun, 10 Apr 2005 20:04:50 +0200 From: Erik Trulsson <ertr1013@student.uu.se> To: Chuck Swiger <cswiger@mac.com> Cc: freebsd-current@freebsd.org Subject: Re: smbfs bug introduced at smbfs_vnops.c:1.58 Message-ID: <20050410180450.GA963@falcon.midgard.homeip.net> In-Reply-To: <42595E04.60705@mac.com> References: <200504100251.j3A2pLEH055107@sana.init-main.com> <20050410074009.N66651@bowser.eecs.harvard.edu> <1892195662.20050410140423@andric.com> <20050410082945.H66651@bowser.eecs.harvard.edu> <42595E04.60705@mac.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Apr 10, 2005 at 01:10:28PM -0400, Chuck Swiger wrote:
> Daniel Ellard wrote:
> >On Sun, 10 Apr 2005, Dimitry Andric wrote:
> [ ... ]
> >At least the gcc folk now do detect this old chestnut:
> >
> > {
> > int a;
> >
> > a /= 0;
> > }
> >
> >which was used to provoke arguments in compiler
> >classes for many years. (Optimized, nothing happens.
> >Unoptimized, a division-by-zero error happens...)
>
> Great example.
>
> If the optimized code fails to generate a division-by-zero error here, the
> optimizer is buggy.
Not at all. Division by zero means undefined behaviour (at least in
C.) Undefined behaviour means *anything* may happen - including no
error happening. A compiler optimizing away the division-by-zero is
perfectly correct in doing so. (It is also perfectly correct to not
optimize away the error.)
> (I won't quote Aho, Sethi, and Ullman again.... :-)
No, please don't - especially since that quote you are so fond of isn't
*quite* correct - an optimizer is allowed to change the output of a
program as long as the new output is also correct according to the
language specification. (Language specifications often do not specify
every detail, with the result that for a given program it can be the
case that more than one output can be correct. In C any instance of
undefined behaviour in a program means that *no* aspect of the program
is defined and therefore all different outputs will be equally
correct.)
--
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050410180450.GA963>
