This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Overflow checking is now on by default


All previous versions of GNAT have set overflow checking off by
default (with -gnato switches to enable overflow checking). This
update sets the default to checking on, and implements a new
switch -gnato0 to turn overflow checking on. The old switch
-gnato, which used to enable overflow checking can still be
used but simply sets the default, so normally has no effect.

The following program:

     1. procedure OvTest is
     2.    A : Integer;
     3.    function Ident (X : Integer) return Integer is
     4.    begin
     5.       return X;
     6.    end;
     7. begin
     8.    A := Ident (Integer'Last) + 1;
     9. end;

raises an exception:

   raised CONSTRAINT_ERROR : ovtest.adb:8 overflow check failed

if compiled with no options or with -gnato, and runs silently
if compiled with -gnato0.

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-07-31  Robert Dewar  <dewar@adacore.com>

	* gnat1drv.adb (Adjust_Global_Switches): Default for overflow
	checking is enabled except in GNAT_Mode.
	* switch-c.adb (Scan_Front_End_Switches): Implement -gnato0
	(suppress overflow checks).

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]