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] Fix undetected overflow case in Ada.Real_Time."/"


Despite the explicit pragma Unsuppress statements, the case of dividing
Time_Span_First by -1 did not raise an exception. Eventually this should
be corrected at the compiler or runtime level, but for now, we add an
explicit check to ensure that this case is caught.

The following test program:

     1. with Ada.Real_Time; use Ada.Real_Time;
     2. procedure ReaTimOv is
     3.    Result : Time_Span;
     4. begin
     5.    Result :=
     6.      Ada.Real_Time."/"
     7.        (Left  => Ada.Real_Time.Time_Span_First,
     8.         Right => -1);
     9. end;

must yield when executed:

raised CONSTRAINT_ERROR : Ada.Real_Time."/": overflow

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

2015-05-12  Robert Dewar  <dewar@adacore.com>

	* a-reatim.adb ("/"): Add explicit check for Time_Span_First / -1.

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]