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 <de...@adacore.com> * a-reatim.adb ("/"): Add explicit check for Time_Span_First / -1.
Index: a-reatim.adb =================================================================== --- a-reatim.adb (revision 223033) +++ a-reatim.adb (working copy) @@ -7,7 +7,7 @@ -- B o d y -- -- -- -- Copyright (C) 1991-1994, Florida State University -- --- Copyright (C) 1995-2014, AdaCore -- +-- Copyright (C) 1995-2015, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -123,6 +123,16 @@ pragma Unsuppress (Overflow_Check); pragma Unsuppress (Division_Check); begin + -- Even though checks are unsuppressed, we need an explicit check for + -- the case of largest negative integer divided by minus one, since + -- some library routines we use fail to catch this case. This will be + -- fixed at the compiler level in the future, at which point this test + -- can be removed. + + if Left = Time_Span_First and then Right = -1 then + raise Constraint_Error with "overflow"; + end if; + return Time_Span (Duration (Left) / Right); end "/";