delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
NNTP-Posting-Date: | Tue, 17 Apr 2007 04:19:19 -0500 |
From: | "Alexei A. Frounze" <alexfru AT chat DOT ru> |
Newsgroups: | comp.os.msdos.djgpp |
References: | <LbadnVsa3_H-ornbnZ2dnUVZ_sudnZ2d AT comcast DOT com> <f01r0r$59u$1 AT aioe DOT org> |
Subject: | Re: gcc bug? |
Date: | Tue, 17 Apr 2007 02:15:49 -0700 |
MIME-Version: | 1.0 |
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: | <G-CdnfEDh5KKDLnbnZ2dnUVZ_jydnZ2d@comcast.com> |
Lines: | 50 |
NNTP-Posting-Host: | 67.170.72.236 |
X-Trace: | sv3-Vvc4PpJzu1eHy7dWDhzpTQP9EXzOr/hm3OQ3Ri4oIhg53NrJ8kaiAF4NHdpAv1V9geFkOwwqvsgX4/d!bdLc+A0ikWofFxb80dRUJHUs9WvA+7FY/0hZGknryfS4+KwAVMcnsa5VOKIu0UZUazY0LX2lNGT4!LzjdVSRZEZPYUgdv95fh1NaTo4pgBw== |
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 |
Rod Pemberton wrote: > "Alexei A. Frounze" <alexfru AT chat DOT ru> wrote in message > news:LbadnVsa3_H-ornbnZ2dnUVZ_sudnZ2d AT comcast DOT com... >> I was checking my understanding of volatile's effect and encountered >> an odd thing. >> > > I'm _really_ unsure about this... The "warning flag" for me are the > additional qualifiers on a type that's already been typedef'd (Is that > legal? Seems to work...except for...). I.e., are your volatile's in > the correct location? You want the pointer to be volatile not the > struct, right? In C in some cases there're at least two ways to express the same thing with the qualifiers. And yes, you can make volatile/constant a variable (of any type), a pointer to any variable/struct, and a variable/struct a pointer points to. And you can even have both the pointer and what it points to volatile or constant. Double volatile doesn't seem to make much sense, while double const is probably a good thing. >> Consider the following code: >> ----8<---- >> typedef struct {char x;} T, *PT; >> >> void f1 () >> { >> volatile T* pt = 0; > > T* volatile pt = 0; These are different. Let's add another typedef and see what we get: typedef volatile T* PVT; volatile T* - non-volatile ptr to volatile var volatile PT - volatile ptr to non-volatile var PVT - non-volatile ptr to volatile var T* volatile - volatile ptr to non-volatile var The catch is that it's easy to confuse volatile T* and volatile PT because they look pretty much the same and it's easy to get fooled and think that PT is merely a macro substitution for T*, which it's not. At any rate, since I don't see a pointer in f1()'s generated asm code, this is a gcc bug. At least in version 3.3.4, at least in DJGPP. Alex
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |