Compiling the attached code with: gnatmake -gnatf -gnatwa -gnatVa -O3 test produces a CONSTRAINT ERROR when run. If I change the compile flags or the code the slightest it seems to run ok (the O3 by itself does not produce an error). I'm using gentoo x86 built gnat-3.43 I've tested the code on gnat-3.15 intel and sparc with OK result. This seems like such a simple error so I'm wondering if GNAT has been built correctly. This is my first bugzilla report. Is there something I should have added to this bug report? Is it misplaced? Reproducible: Always Steps to Reproduce: 1. Compile the code below with gnatmake -gnatf -gnatwa -gnatVa -O3 test with Text_IO; with Interfaces; with Ada.Streams.Stream_IO; procedure Test is F : Ada.Streams.Stream_IO.File_Type; S : Ada.Streams.Stream_IO.Stream_Access; Filename : constant String := "testnumbers"; use Interfaces; begin Ada.Streams.Stream_IO.Create (F, Name => Filename); S := Ada.Streams.Stream_IO.Stream (F); Interfaces.IEEE_Float_32'Output (S, -3.40282E+38); Interfaces.IEEE_Float_32'Output (S, 3.40282E+38); Interfaces.IEEE_Float_64'Output (S, -1.79769313486231E+308); Interfaces.IEEE_Float_64'Output (S, 0.0); Ada.Streams.Stream_IO.Close (F); -------------------------------- Ada.Streams.Stream_IO.Open (F, Ada.Streams.Stream_IO.In_File, Name => Filename); S := Ada.Streams.Stream_IO.Stream (F); if Interfaces.IEEE_Float_32'Input (S) = -3.40282E+38 and Interfaces.IEEE_Float_32'Input (S) = 3.40282E+38 then Text_IO.Put_Line ("OK"); end if; if Interfaces.IEEE_Float_64'Input (S) = -1.79769313486231E+308 and Interfaces.IEEE_Float_64'Input (S) = 0.0 then Text_IO.Put_Line ("OK"); end if; Ada.Streams.Stream_IO.Close (F); end Test; Actual Results: A runtime exception.
Hi Bj
Hi Björn. Thank you for this report and sorry for a delay - we had a problem with Ada maintainership for a while and lately I was reorganizing stuff. Do you still have this problem with later gnat compilers in the tree? I just tested it with gnat-gpl-3.4.6.2006 and gnat-gcc-4.1.1 and both do not trigger it. It is likely that was a transient problem with FSF's gnat at the time, long since fixed. Therefore I am closing this bug now. Please reopen if problem persists. George PS BTW, in your test example the "and"'s in value checks should have been "and then"'s, as otherwise gnat is not obliged to maintains the order of operations in the conditional expression and you may happen to read the values in the reverse order. Granted, gnat has no particular reason to rearrange them here, but it is better to play it safe. Still, CONSTRAINT_ERROR should not have been triggered in either case, so I don't think this was the problem.