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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news4.google.com!feeder.news-service.com!proxad.net!feeder1-2.proxad.net!cleanfeed2-a.proxad.net!nnrp4-1.free.fr!not-for-mail Date: Sat, 10 Oct 2009 00:15:35 +0200 From: Damien Carbonne User-Agent: Thunderbird 2.0.0.23 (X11/20090812) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: GNAT GPL 2009 - issue with floating points? References: <4acf9ee2$0$23472$426a34cc@news.free.fr> <6d8f169d-5dc8-465c-9368-be91efc2de0f@v15g2000prn.googlegroups.com> In-Reply-To: <6d8f169d-5dc8-465c-9368-be91efc2de0f@v15g2000prn.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <4acfb607$0$412$426a34cc@news.free.fr> Organization: Guest of ProXad - France NNTP-Posting-Date: 10 Oct 2009 00:15:36 MEST NNTP-Posting-Host: 82.247.219.63 X-Trace: 1255126536 news-4.free.fr 412 82.247.219.63:47933 X-Complaints-To: abuse@proxad.net Xref: g2news2.google.com comp.lang.ada:8640 Date: 2009-10-10T00:15:36+02:00 List-Id: Adam Beneschan a �crit : > On Oct 9, 1:36 pm, Damien Carbonne wrote: >> Hi, >> >> When compiling the following sample code with GNAT GPL 2009 on Linux: >> >> generic >> type Real is digits <>; >> package Pack04 is >> Size1 : constant := Real'Size; >> Size2 : constant Integer := Real'Size; >> end Pack04; >> >> I get this: >> >> -- pack04.ads:4:24: non-static expression used in number declaration >> -- pack04.ads:4:28: size attribute is only static for scalar type (RM >> 4.9(7,8)) >> >> RM 3.5(1): "scalar types comprise enumeration types, integer types, and >> real types." >> >> RM 3.5.6 (1): "Real types provide approximations to the real numbers, >> with relative bounds on errors for floating point types, and with >> absolute bounds for fixed point types." > > Did you read the RM reference that the GNAT error message pointed you > to??? Yes I did ! It is very possible that this code is wrong (this is not really the problem here), but why does the message say that "size attribute is only static for scalar types" as an explanation, when the type the size attribute is applied to is precisely a scalar ! At least, I thought that floating points were scalars in Ada till this evening ! I read this message as: "As Real is a scalar type, I can apply size attribute to Real and obtain a static expression." This reading is apparently wrong. Do you mean that the formal generic parameter Real is not a scalar? I'm certainly no an Ada expert, but I really find the message confusing. > > Also read 4.9(26). > >> So Real is supposed to be a scalar! >> >> Is this a problem with (misleading) message or with (effectively) wrong >> code? > > The code is wrong. Sure, but I still find the message misleading. Isn't Real a scalar type? > > And anyway, the declaration of Size2 is legal (even though the > declaration of Size1 isn't), so there's no problem. The problem is that even if Size2 is a correct declaration, there are other latter issues with its use, not shown in the sample code. > > -- Adam >