Ada and NTPL

Chris Proctor chrisp@bigpond.com
Thu Apr 24 11:39:00 GMT 2003


On Thu, Apr 24, 2003 at 09:12:18AM +0200, Laurent Guerby wrote:
> I did succeed at get tasking working on Red Hat 9 x86 and NTPL
> using the ACT tree (HEAD + gcc-head as of 23Apr2003 around 20:00 GMT)
> and GCC mainline. The resulting compiler gets much better results than
> 3.2 and results in line with the ACT 5.00 release
> except for a miscompilation of a-calend.adb that gives 17 failures.
> 
> For the record here is a reduced test case:
> 
> with Ada.Calendar;
> procedure P1 is
>    Some_Time : Ada.Calendar.Time;
> begin
>    Some_Time := Ada.Calendar.Time_Of (Month => 9, Day => 16, Year => 1993);
> end P1;
> $ gnatmake p1
> $ ./p1
> 
> raised CONSTRAINT_ERROR : a-calend.adb:418 explicit raise
> $
> 
> The code failing in Ada.Calendar is:
> 
>       if        not Year   'Valid
>         or else not Month  'Valid
>         or else not Day    'Valid
>         or else not Seconds'Valid
>       then
>          raise Constraint_Error;
>       end if;
> 
> I did check the assembly.
> 

The Seconds'Valid check is what failing.
This only miscompiles with optimisation and appears to be i386 only failure
(sparc-solaris works correctly).

This is failure is documented in ada/9536 and ada/9129 and
in message thread starting at
<http://gcc.gnu.org/ml/gcc/2002-12/msg00167.html>

The 'Valid check is optimized into False no matter what the actual
value of the parameter is.

Below is a more accurate test case:

--
--  Testcase for ada/9536, ada/9129
--

with Ada.Text_IO;

procedure Ada9536 is

  type Day_Duration is new Duration range 0.0 .. 86400.0;

  function Valid_Test (D : in Day_Duration) return Boolean is
  begin
    return D'Valid;
  end Valid_Test;

begin

  if Valid_Test (0.0) then
    Ada.Text_IO.Put_Line ("PASSED");
  else
    Ada.Text_IO.Put_Line ("FAILED");
  end if;

end Ada9536;



More information about the Gcc mailing list