------- Comment #1 from ludovic at ludovic-brenta dot org  2007-02-09 14:34 
-------
Shorter test case that reproduces the problem.

with Ada.Text_IO;
procedure test1 is
   type T1 is mod 9;
   package T1_IO is new Ada.Text_IO.Modular_IO(T1);
   X: T1 := 8;
   J1: constant := 5;
begin
   for J2 in 5..5 loop
      pragma assert(X*(2**J1) = X*(2**J2));
      if X*(2**J1) /= X*(2**J2) then
         Ada.Text_IO.Put_Line("Failed");
         T1_IO.Put(X*(2**J1));
         T1_IO.Put(X*(2**J2));
         Ada.Text_IO.New_Line;
      end if;
   end loop;
end test1;

prints:

   Failed
    4 0

To reproduce: gnatmake test1

To reproduce with correct behaviour (no output): gnatmake -gnato test1

Notice that when multiplying by 2**J1, the result is always correct because J2
is a named number and the calculation is done at compile time with the correct
semantics.  In contrast, J2 is non-static and exhibits the wrong semantics
unless we add -gnato.

Problem reproduced with GCC 4.1.1 but it's been there ever since 3.15p or even
before.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30740

Reply via email to