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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.36.124.13 with SMTP id a13mr4320965itd.1.1498834150515; Fri, 30 Jun 2017 07:49:10 -0700 (PDT) X-Received: by 10.36.69.103 with SMTP id y100mr334705ita.0.1498834150493; Fri, 30 Jun 2017 07:49:10 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!v202no254260itb.0!news-out.google.com!s132ni2715itb.0!nntp.google.com!v202no254256itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 30 Jun 2017 07:49:10 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=24.6.20.197; posting-account=Qh2kiQoAAADpCLlhT_KTYoGO8dU3n4I6 NNTP-Posting-Host: 24.6.20.197 References: <88752790-dedc-4185-aba9-b70361e59d19@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: bug compiler ? From: Anh Vo Injection-Date: Fri, 30 Jun 2017 14:49:10 +0000 Content-Type: text/plain; charset="UTF-8" Xref: news.eternal-september.org comp.lang.ada:47230 Date: 2017-06-30T07:49:10-07:00 List-Id: On Friday, June 30, 2017 at 4:09:31 AM UTC-7, Lucretia wrote: > On Friday, 30 June 2017 09:49:59 UTC+1, bbab...@gmail.com wrote: > > Hello everyone, > > > > I tried to compile this > > > > procedure bug is > > type my_int is new integer; > > type access_function_my_int is access function (n : my_int) return my_int; > > function f (n : my_int) return my_int is (n); > > a : access_function_my_int :=f'access; > > begin > > null; > > end bug; > > > > with the command line : gcc -c -gnat2012 bug.adb > > > > and then I get this message from the compiler: > > > > > > raised STORAGE_ERROR : stack overflow or erroneous memory access > > > > If I modify the type "my_int" by writing subtype my_int is integer; > > then I dont get any error from the compiler. > > > > More interesting, if in the first program, the function f is no longer written inline, then I dont get any error. > > > > Does anyone know what's happeing ? > > You can't create a local pointer to f or anything there, you have to define it in a package. You're essentially trying to create a pointer on the stack to something else on the stack. There is a way around it, I think unchecked_conversion, not sure now. > The compiler should reject it if it does not compile with syntax rule. In this case, it does compile. In fact, if the function expression is replaced by normal function, it compiles fine. Therefore, a bug report should be sent to gnat@adacore.com. Anh Vo