smbfs bug introduced at smbfs_vnops.c:1.58

Erik Trulsson ertr1013 at
Sun Apr 10 11:04:55 PDT 2005

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

<Insert your favourite quote here.>
Erik Trulsson
ertr1013 at

More information about the freebsd-fs mailing list