comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: expression function bug or think?
Date: Thu, 16 Jun 2011 21:41:21 +0100
Date: 2011-06-16T21:41:21+01:00	[thread overview]
Message-ID: <m2tybp1pce.fsf@pushface.org> (raw)
In-Reply-To: 87wrglwmao.fsf@mid.deneb.enyo.de

Florian Weimer <fw@deneb.enyo.de> writes:

> Out of curiosity, can you show us the expanded Ada code, using -gnatG?

GNAT GPL 2011, with -gnatp:

functions_E : short_integer := 0;

package functions is
   function functions__fib (n : natural) return natural;

   function functions__fib (n : natural) return natural is
   begin
      return
         do
            T2s : natural;
            case n is
               when 0 =>
                  T2s := 0;
               when 1 =>
                  T2s := 1;
               when others =>
                  T2s := functions__fib (n - 1) + functions__fib (n -
                    2);
            end case;
         in T2s end
      ;
   end functions__fib;
end functions;

GNAT GPL 2011, without -gnatp:

functions_E : short_integer := 0;

package functions is
   function functions__fib (n : natural) return natural;

   function functions__fib (n : natural) return natural is
   begin
      return
         do
            T2s : natural;[constraint_error when
              not (n - 1 >= 0)
              "range check failed"][constraint_error when
              not (n - 2 >= 0)
              "range check failed"][constraint_error when
              not (interfaces__unsigned_32!(n) <= 16#7FFF_FFFF#)
              "invalid data"]
            case n is
               when 0 =>
                  T2s := 0;
               when 1 =>
                  T2s := 1;
               when others =>
                  T2s := functions__fib (n - 1) + functions__fib (n -
                    2);
            end case;
         in T2s end
      ;
   end functions__fib;
end functions;



Pretty conclusive, I think!



  reply	other threads:[~2011-06-16 20:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-16 11:00 expression function bug or think? georg bauhaus
2011-06-16 11:27 ` AdaMagica
2011-06-16 15:56 ` Adam Beneschan
2011-06-17  3:56   ` Yannick Duchêne (Hibou57)
2011-06-16 16:16 ` Anh Vo
2011-06-16 18:56 ` Bill Findlay
2011-06-16 19:18   ` Simon Wright
2011-06-16 20:03     ` Georg Bauhaus
2011-06-16 20:03     ` Bill Findlay
2011-06-16 20:31 ` Florian Weimer
2011-06-16 20:41   ` Simon Wright [this message]
2011-06-16 21:14     ` Georg Bauhaus
2011-06-16 23:14     ` Bill Findlay
2011-06-17  9:34     ` Martin
2011-06-17 10:33       ` Simon Wright
2011-06-17 10:39         ` Martin
2011-06-17 11:09           ` Niklas Holsti
2011-06-16 21:04   ` Georg Bauhaus
2011-06-17  8:55   ` Georg Bauhaus
2011-06-17  9:10     ` Georg Bauhaus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox