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-Thread: a07f3367d7,461d464a39a7a30a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 X-Received: by 10.180.75.133 with SMTP id c5mr2930298wiw.2.1367665984326; Sat, 04 May 2013 04:13:04 -0700 (PDT) Path: hg5ni66847wib.1!nntp.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!backlog1.nntp.dca.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeed.news.ucla.edu!nrc-news.nrc.ca!News.Dal.Ca!news.litech.org!news.stack.nl!aioe.org!.POSTED!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: Erroneous code generation from GNAT or GCC? Date: Mon, 29 Apr 2013 03:35:53 +0200 Organization: Ada @ Home Message-ID: References: NNTP-Posting-Host: ZXqOjp+NNxswgqXUj66j5g.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.15 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 X-Original-Bytes: 4288 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable Date: 2013-04-29T03:35:53+02:00 List-Id: Le Mon, 29 Apr 2013 01:52:22 +0200, Yannick Duch=C3=AAne (Hibou57) = a =C3=A9crit: > Until now, I though the volatile aspect was typically to be used with = = > object which may be updated as a non=E2=80=91visible side effect, like= with a = > peripheral writing at some memory area [=E2=80=A6] This way of understanding things must not be entirely wrong. In the above solution involving volatile (once again, like in the other = = thread), the object is locally constant, as it is assigned, and never = modified. So wanted to turn its declaration into this: Element : constant Character :=3D Item with Volatile =3D> True; But GNAT complained, with a trustable reason, as it refers to the RM: stand alone volatile constant must be imported (RM C.6(13)) Here, according to the RM, a volatile constant declared in the Ada world= = and initialized in the Ada world, is not a valid candidate for a volatil= e = aspect: RM C.6(13) says: > If an aspect Volatile, Volatile_Components, Atomic, orAtomic_Component= s = > is directly specified to have the valueTrue for a stand-alone constant= = > object, then the aspectImport shall also be specified as True for it. (oops, the `Import` aspect is not of boolean type =E2=80=A6but what it m= eans is = still clear) This suggest if the object is not modified, then the volatile aspect = should not be required, unless the so=E2=80=91called constant is not a c= onstant in = the strict Ada meaning (imported from the external world, and so which m= ay = be initialized who=E2=80=91know=E2=80=91when, and may also be modified l= ater, externally). What would help, is a way to tell the compiler the address is used, not = = for its own, but for what it refers to. If all parameters must be volatile when there address attribute is used,= = that implies systematic copy of everything, as types defined for Ada = programs, are not to be volatile. Ex. each string should be copied to an= = array of characters whose components are volatile (there is a = `Volatile_Components` aspect). Surprisingly, there is not such issue (or I've just never encountered an= y = case?) when linking to similar sub=E2=80=91programs in C or assembly and= declared = imported: there is no need to tell what's referred to by a pointer, is = really needed. I wanted to try to use machine=E2=80=91code insertion, to= have most = of or all things in Ada packages and to benefit from Ada checking. I feel to not really understand how machine=E2=80=91code insertion works= or is = defined (especially when optimization is enabled), and it looks to me, = surprisingly a lot harder to set=E2=80=91up than linking to similar impo= rted = sub=E2=80=91programs. So now, I'm seeking for something which would have the effect of a (an = invalid) `pragma Volatile (Item'Address'Memory)` which seems to be = implicit or not required when interfacing to C. -- = =E2=80=9CSyntactic sugar causes cancer of the semi-colons.=E2=80=9D [1] =E2=80=9CStructured Programming supports the law of the excluded muddle.= =E2=80=9D [1] [1]: Epigrams on Programming =E2=80=94 Alan J. =E2=80=94 P. Yale Univers= ity