Package: gnat
Version: 4.6
Severity: normal
Tags: patch

Dear Maintainer,

The program attached to this report reflects a finding
in c.l.ada, Jan 2014, "How to round to the nearest
fixed-point value",
Message-ID: <slrnldvtim.1lme.lithium...@sigil.instinctive.eu
which has been classified as a compiler bug. The program
should run as is, with no output. Instead, it raises
Program_Error because the value of 0.999, rounded to 3 digits,
is not 1.00, but 0.99.

procedure Round_Decimal is

   --  OJBECTIVE:
   --    Check that 'Round of a decimal fixed point type does round
   --    away from zero if the operand is of a decimal fixed point
   --    type with a smaller delta.

   type Milli is delta 0.001 digits 9;
   type Centi is delta 0.01 digits 9;

   function Rounded (Value : Milli) return Centi;
   --  Value, rounded using Centi'Round

   function Rounded (Value : Milli) return Centi is
   begin
      return Centi'Round (Value);
   end Rounded;

begin

   --  Operands used directly:

   if not (Milli'Round (0.999) = Milli'(0.999)
             and
           Centi'Round (0.999) = Centi'(1.0)
             and
           Centi'Round (Milli'(0.999)) = Centi'(1.0))
   then
      raise Program_Error;
   end if;

   --  This is expected to fail, currently, but shouldn't:

   if Rounded (Milli'(0.999)) /= Centi'(1.0) then
      raise Program_Error;
   end if;

end Round_Decimal;


-- System Information:
Debian Release: 7.3
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 3.2.0-4-686-pae (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages gnat depends on:
ii  gnat-4.6  4.6.3-8

Versions of packages gnat recommends:
pn  ada-reference-manual  <none>
pn  gnat-gps              <none>

gnat suggests no packages.

-- no debconf information


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to