X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f NNTP-Posting-Date: Wed, 18 Apr 2007 21:17:31 -0500 From: "Alexei A. Frounze" Newsgroups: comp.os.msdos.djgpp References: <200704181529 DOT l3IFT3UV004286 AT localhost DOT localdomain> Subject: Re: gcc bug? Date: Wed, 18 Apr 2007 19:14:11 -0700 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="koi8-r"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3028 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 Message-ID: <3bGdnV_ErqKmTLvbnZ2dnUVZ_sWdnZ2d@comcast.com> Lines: 26 NNTP-Posting-Host: 67.170.72.236 X-Trace: sv3-4yGhW0ca7rFhv0YriURK9VMuwopz0xNxN2ESbPTswuZzCRIb1+Vuo5qEPh2jsK7YLb5u2tgs/XNJ4CL!Iw5b+ME2KByl/lT9dunjJUNpnrT4aWaF8wJtfgQ+P5VaBKjU4hCpRuoyyG83atdcWxuf9O0VMWB3!ElFhdqYfGHwLUyqNHP3Oc9nCTd1y4g== X-Complaints-To: abuse AT comcast DOT net X-DMCA-Complaints-To: dmca AT comcast DOT net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.34 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Alexei A. Frounze wrote: > DJ Delorie wrote: >> Part of the problem may be that your volatile variable is on the >> stack, rather than being a global or static variable. You've also >> defined it as "pointer to volatile T" not "volatile pointer to T". > > But from where did gcc get the idea of the variable (to which the > pointer points, at address 0) being zero? Oh, I see. If in f1() I assign the pointer to 1, then the asm output (obtained with -O2 optimization switch) is this: _f1: pushl %ebp movl %esp, %ebp .p2align 4,,7 L2: movb 1, %al testb %al, %al jne L2 popl %ebp ret For some reason the compiler decides that the pointer to the variable and that variable are the same thing. Alex