Re: how to make gcc warn about arithmetic signed overflow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2013-09-21 at 18:46 +0200, wempwer@xxxxxxxxx wrote:
> int ab = 50000;
> int bc = 50000;
> int r = ab * bc;
> 
> Is it possible for gcc to produce a
> warning in such situation?

Yes, gcc the Gnu Compiler Collection can produce such a warning:

procedure test_ovf is
   ab : integer := 50000;
   bc : integer := 50000;
   r : integer := ab * bc;
begin
   null;
end test_ovf;

gcc -c test_ovf.adb
test_ovf.adb:4:22: warning: value not in range of type
"Standard.Integer"
test_ovf.adb:4:22: warning: "Constraint_Error" will be raised at run
time
However I'm not sure it is allowed to do the same with C. 

- Brian





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux