C compiler problems

Mike McNally m5 at bobkat.UUCP
Wed Feb 3 03:25:10 AEST 1988


Here's a good one I came across this morning.  Here's an expression:

    register unsigned long i;

    i = ((unsigned long) 0xffffffff / 10);

Guess what the variable ``i'' is set to?  Zero!  The compiler just
generates a CLRL instruction.  Obviously the constant folding code
does not include a special case for ``unsigned long''.

The bug is present in our in-house compiler, in GNU CC, and in the
Integrated Solutions 4.2 UNIX compiler.  Green Hills generates
correct code.

-- 
Mike McNally, mercifully employed at Digital Lynx ---
    Where Plano Road the Mighty Flood of Forest Lane doth meet,
    And Garland fair, whose perfumed air flows soft about my feet...
uucp: {texsun,killer,infotel}!pollux!bobkat!m5 (214) 238-7474



More information about the Comp.lang.c mailing list