Constant overflow

John Sambrook john at uw-nsr.UUCP
Mon Mar 14 05:27:56 AEST 1988


In article <2747 at mmintl.UUCP> franka at mmintl.UUCP (Frank Adams) writes:
>
>Try this one on your favorite C compiler.  So far, every one I've tried
>(including lint) has had no complaint:
>
>	long i = 9876543210L;
>
>(The problem, of course, is that that number doesn't fit in 32 bits.  If
>your compiler has a word size of more than 32 bits, try something big
>enough to overflow whatever it uses.)

Ok, here is the output I get on our DG MV/10000 running DG/UX 3.11 and
DG/UX C 3.90.14:

Script started on Sun Mar 13 11:18:20 1988
% cat main.c

main()
{
        long i = 9876543210L;
}

% cc main.c -o main
Error 104 severity 2 beginning on line 4 (Line 4 of file main.c)
        long i = 9876543210L;
                 ^
The int constant "9876543210L" could not fit into 32 bits without
a loss of precision.  The compiler truncated it on the left.
 
% ^D
Script done at Sun Mar 13 11:19:06 1988
    
-- 
John Sambrook                        Internet: john at nsr.bioeng.washington.edu
University of Washington RC-05           UUCP: uw-nsr!john
Seattle, Washington  98195               Dial: (206) 548-4386



More information about the Comp.lang.c mailing list