From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,ed872c72866dab2b X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!news4.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Bill Findlay Newsgroups: comp.lang.ada Subject: Re: expression function bug or think? Date: Thu, 16 Jun 2011 19:56:31 +0100 Message-ID: References: <678085105329914667.504682rmhost.bauhaus-maps.arcor.de@news.arcor.de> Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Trace: individual.net yW6MCn4IeYepVA2RGEbUgA1ipxnQjVb+Z0I1CnneuXR9BZZ2J+ Cancel-Lock: sha1:nqu51rJm/Jqs8sClwUmdbLNZWis= User-Agent: Microsoft-Entourage/12.28.0.101117 Thread-Topic: expression function bug or think? Thread-Index: AcwsVxrIdrJoyrvwVUiOC0TEycnkNQ== Xref: g2news1.google.com comp.lang.ada:19886 Date: 2011-06-16T19:56:31+01:00 List-Id: On 16/06/2011 12:00, in article 678085105329914667.504682rmhost.bauhaus-maps.arcor.de@news.arcor.de, "georg bauhaus" wrote: > When I compile the following program with GNAT GPL 2011 on Mac, > I get confusingly different behavior depending on whether > or not I suppress checks. Strange. On Snow Leopard 10.6.7, I compile and run: > /Users/wf/: gnatmake -gnat12 -gnatl run_fib.adb > gcc -c -gnat12 -gnatl run_fib.adb > > GNAT GPL 2011 (20110419) > Copyright 1992-2011, Free Software Foundation, Inc. > > > Compiling: run_fib.adb (source file time stamp: 2011-06-16 18:50:24) > > 1. with Functions; > 2. with Ada.Text_IO; > 3. > 4. procedure Run_Fib is > 5. N : Natural; > 6. begin > 7. if Functions.Fib(0) /= 0 then > 8. raise Program_Error; > 9. end if; > 10. N := Functions.Fib(10); > 11. Ada.Text_IO.Put_Line ("fib(10) =" & Natural'Image(N)); > 12. end Run_Fib; > > 12 lines: No errors > gcc -c -gnat12 -gnatl functions.ads > > GNAT GPL 2011 (20110419) > Copyright 1992-2011, Free Software Foundation, Inc. > > > Compiling: functions.ads (source file time stamp: 2011-06-16 18:51:28) > > 1. package Functions is > 2. function Fib (N : Natural) return Natural is > 3. (case N is > 4. when 0 => 0, > 5. when 1 => 1, > 6. when others => Fib(N-1) + Fib(N-2)); -- L.6 > 7. end Functions; > > 7 lines: No errors > gnatbind -x run_fib.ali > gnatlink run_fib.ali > > > /Users/wf/: ./run_fib > fib(10) = 55 The -gnatp option makes no difference. -- Bill Findlay with blueyonder.co.uk; use surname & forename;