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,XPRIO autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2ba85481fb17d75b,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-01-09 18:36:05 PST Path: supernews.google.com!sn-xit-03!supernews.com!freenix!sunqbc.risq.qc.ca!newsfeed.mathworks.com!news.voicenet.com!news3.voicenet.com.POSTED!not-for-mail From: "Wayne Bullaughey" Newsgroups: comp.lang.ada Subject: volatile with gnat X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Message-ID: <8RP66.4566$Gf6.42244@news3.voicenet.com> Date: Wed, 10 Jan 2001 02:32:36 GMT NNTP-Posting-Host: 207.103.134.42 X-Complaints-To: abuse@voicenet.com X-Trace: news3.voicenet.com 979093956 207.103.134.42 (Tue, 09 Jan 2001 21:32:36 EST) NNTP-Posting-Date: Tue, 09 Jan 2001 21:32:36 EST Xref: supernews.google.com comp.lang.ada:3847 Date: 2001-01-10T02:32:36+00:00 List-Id: The volatile pragma seems to be ignored by gnat version 3.13p when optimization O2 is set unless I am missing something. All the versions of gnat I have tried including Linux Intel native, NT Intel native, Solaris Sparc native, Linux Intel X MIPS cross generate similar code. The following source exhibits the problem: procedure vol is x : integer; pragma Volatile (x); begin x := 0; while x = 0 loop null; end loop; end vol; The NT Intel code generated is: vol.o: file format pe-i386 Disassembly of section .text: 00000000 <__ada_vol>: 0: 55 pushl %ebp 1: 89 e5 movl %esp,%ebp 3: 83 ec 04 subl $0x4,%esp 6: c7 45 fc 00 00 movl $0x0,0xfffffffc(%ebp) b: 00 00 d: 8b 45 fc movl 0xfffffffc(%ebp),%eax 10: 85 c0 testl %eax,%eax 12: 75 08 jne 1c <__ada_vol+1c> 14: 8b 45 fc movl 0xfffffffc(%ebp),%eax 17: 90 nop 18: 85 c0 testl %eax,%eax 1a: 74 fc je 18 <__ada_vol+18> 1c: 89 ec movl %ebp,%esp 1e: 5d popl %ebp 1f: c3 ret The generated code loads x into a register and then tests the register value in the loop. My understanding of the volatile pragma is that the register must be reloaded from the memory location. Version 3.11p generated correct code. I have not tried 3.12p. In my actual application I use a for x'address use statement to map x to special hardware address that I need to test. Having this type of clause does not seem to affect the generated code. My apologies if this is the wrong forum for discussing gnat specific issues. Is there a more appropriate place? I will also submit this to Act. Wayne Bullaughey