[comp.lang.c] C compiler problems

m5@bobkat.UUCP (Mike McNally ) (02/03/88)

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