Re: volatile semantics

2005-07-25 Thread Olivier Galibert
On Sun, Jul 17, 2005 at 11:56:46AM -0700, Geoffrey Keating wrote: > "D. Hugh Redelmeier" <[EMAIL PROTECTED]> writes: > > An object that has volatile-qualified type may be modified in ways > > unknown to the implementation or have other unknown side > > effects. Therefore any expression referring to

Re: volatile semantics

2005-07-23 Thread Mike Stump
On Friday, July 22, 2005, at 06:28 PM, Geoff Keating wrote: I am discussing here only with what GCC *could* do, and still be standards-conforming. What it *should* do is a different > conversation. You will have to explain the benefits to me of having discussions on this list of discussing th

Re: volatile semantics

2005-07-23 Thread Paul Schlie
(sorry, with intended statement this time) > From: Geoff Keating <[EMAIL PROTECTED]> > On 22/07/2005, at 7:15 PM, Paul Schlie wrote: > >>> Geoffrey Keating writes: > >>> without 'volatile', then this object cannot be modified unknown to >>> the implementation, even if someone also writes '(*(vol

Re: volatile semantics

2005-07-23 Thread Paul Schlie
> From: Geoff Keating <[EMAIL PROTECTED]> > On 22/07/2005, at 7:15 PM, Paul Schlie wrote: > >>> Geoffrey Keating writes: > >>> without 'volatile', then this object cannot be modified unknown to >>> the implementation, even if someone also writes '(*(volatile int *)&i) >>> = 1'. >> >> - merely me

Re: volatile semantics

2005-07-23 Thread Geoff Keating
On 22/07/2005, at 7:15 PM, Paul Schlie wrote: Geoffrey Keating writes: without 'volatile', then this object cannot be modified unknown to the implementation, even if someone also writes '(*(volatile int *)&i) = 1'. - merely means: treat the object being referenced as volatile qualif

Re: volatile semantics

2005-07-23 Thread Geoff Keating
On 22/07/2005, at 7:57 PM, Gabriel Dos Reis wrote: There is a "semantics of access". It is implementation-defined. I think you're thinking of "what constitutes an access", which is implementation-defined, but is not the same of the semantics of an access. The standard describes things

Re: volatile semantics

2005-07-22 Thread Ian Lance Taylor
Geoff Keating <[EMAIL PROTECTED]> writes: > This is part of what I meant by saying that your model isn't a match > for the model in the standard. Your model had semantics attached to > the access. Despite evident appearances, I wasn't trying to make an argument from the standard. I was trying t

Re: volatile semantics

2005-07-22 Thread Gabriel Dos Reis
Geoff Keating <[EMAIL PROTECTED]> writes: | On 22/07/2005, at 4:33 PM, Ian Lance Taylor wrote: | | > Geoffrey Keating <[EMAIL PROTECTED]> writes: | > | >> Although I can see that this is how you might think about the | >> semantics of 'const' and 'volatile', I don't think they're an exact | >> ma

Re: volatile semantics

2005-07-22 Thread Paul Schlie
> Geoffrey Keating writes: > > int i; - merely means: allocate and treat all references to the object as referencing an unqualified int object, unless re-qualified within a more local scope. > without 'volatile', then this object cannot be modified unknown to the > implementation, even if som

Re: volatile semantics

2005-07-22 Thread Geoff Keating
On 22/07/2005, at 4:33 PM, Ian Lance Taylor wrote: Geoffrey Keating <[EMAIL PROTECTED]> writes: Although I can see that this is how you might think about the semantics of 'const' and 'volatile', I don't think they're an exact match for the model in the standard. In fact, I think you could ex

Re: volatile semantics

2005-07-22 Thread Ian Lance Taylor
Geoffrey Keating <[EMAIL PROTECTED]> writes: > > const is inherently a characteristic of the object. It applies at > > definition time. Casting away const in a reference does not change > > the definition. Whether making an assignment through a pointer after > > casting away const is legal depe

Re: volatile semantics

2005-07-22 Thread Geoffrey Keating
Ian Lance Taylor writes: > Daniel Berlin <[EMAIL PROTECTED]> writes: > > > > In other words, we're asked to agree that the type of an object > > > changes depending on how it is accessed. > > > For the benefit of readers, only the first sentence of this para is > > > the language of the standard

Re: volatile semantics

2005-07-22 Thread Geoffrey Keating
"D. Hugh Redelmeier" <[EMAIL PROTECTED]> writes: > 6.3.2.1: when an object is said to have a particular type, the type is > specified by the lvalue used to designate the object. So the lvalue > having a volatile-qualified type *means* that the object it designates has > a volatile-qualified type

Re: volatile semantics

2005-07-19 Thread Paul Schlie
> From: Gabriel Dos Reis <[EMAIL PROTECTED]> > Paul Schlie <[EMAIL PROTECTED]> writes: > > | > Gabriel Dos Reis writes: > | > If by analysis, you can determine ... > | > | The problem with this type of logic is that it leads to arbitrary > | inconsistent designation of an object's reference as a

Re: volatile semantics

2005-07-19 Thread Gabriel Dos Reis
Paul Schlie <[EMAIL PROTECTED]> writes: | > Gabriel Dos Reis writes: | > If by analysis, you can determine ... | | The problem with this type of logic is that it leads to arbitrary | inconsistent designation of an object's reference as a function of | the breadth of the "analysis", therefore seem

Re: volatile semantics

2005-07-19 Thread Paul Schlie
> Gabriel Dos Reis writes: > If by analysis, you can determine ... The problem with this type of logic is that it leads to arbitrary inconsistent designation of an object's reference as a function of the breadth of the "analysis", therefore seems clearly undesirable. Resulting in only two possibi

Re: volatile semantics

2005-07-19 Thread Gabriel Dos Reis
[EMAIL PROTECTED] (Kai Henningsen) writes: | [EMAIL PROTECTED] (Gabriel Dos Reis) wrote on 17.07.05 in <[EMAIL PROTECTED]>: | | > Daniel Berlin <[EMAIL PROTECTED]> writes: | > | > | On Sun, 2005-07-17 at 00:05 +0200, Gabriel Dos Reis wrote: | > | > Daniel Berlin <[EMAIL PROTECTED]> writes: | >

Re: volatile semantics

2005-07-19 Thread Kai Henningsen
[EMAIL PROTECTED] (Gabriel Dos Reis) wrote on 17.07.05 in <[EMAIL PROTECTED]>: > Daniel Berlin <[EMAIL PROTECTED]> writes: > > | On Sun, 2005-07-17 at 00:05 +0200, Gabriel Dos Reis wrote: > | > Daniel Berlin <[EMAIL PROTECTED]> writes: > | > > | > [...] > | > > | > | You make it sound like the s

Re: volatile semantics

2005-07-18 Thread Mike Stump
On Jul 17, 2005, at 4:48 AM, Gabriel Dos Reis wrote: C++ has resisted, for two decades, the temptation of "improving" the meaning of volatile :-) considering that it is C's baby. Do you know what the semantics of: a; are in C and C++? :-(

Re: volatile semantics

2005-07-18 Thread Gabriel Dos Reis
Mike Stump <[EMAIL PROTECTED]> writes: | On Jul 17, 2005, at 4:48 AM, Gabriel Dos Reis wrote: | > C++ has resisted, for two decades, the temptation of "improving" the | > meaning of volatile :-) considering that it is C's baby. | | Do you know what the semantics of: | | a; | | are in C and

Re: volatile semantics

2005-07-18 Thread D. Hugh Redelmeier
| From: Paul Schlie <[EMAIL PROTECTED]> | > | void foo(void) { | > |int *x = 4; | > | *x = 3; | The point I was attempting to make, was that just because a specified | statement's effective behavior/side-effects are not well defined, it doesn't | mean that it's clearly specif

Re: volatile semantics

2005-07-18 Thread Paul Schlie
> From: Gabriel Dos Reis <[EMAIL PROTECTED]> > | - Just as if given: > | > | void foo(void) { > |int *x = 4; > | *x = 3; The point I was attempting to make, was that just because a specified statement's effective behavior/side-effects are not well defined, it doesn't mean tha

Re: volatile semantics

2005-07-18 Thread Gerald Pfeifer
On Sun, 17 Jul 2005, D. Hugh Redelmeier wrote: > If GCC4 causes this much problem with X, I wonder what GCC4 will do to > the Linux kernel. Current combinations of the Linux kernel and GCC 4.0 seem to work just fine, as far as I can tell. Gerald

Re: volatile semantics

2005-07-18 Thread Paul Schlie
> From: Jonathan Wakely <[EMAIL PROTECTED]> > On Sun, Jul 17, 2005 at 09:29:11PM -0400, Paul Schlie wrote: > >>> Note that I'm explicitly not taking a position on what the standard says. >>> The standard is notoriously incomplete with respect to object model issues, >>> including volatility, so I

Re: volatile semantics

2005-07-18 Thread Gabriel Dos Reis
Paul Schlie <[EMAIL PROTECTED]> writes: | > From: Paul Schlie <[EMAIL PROTECTED]> | >> From: Gabriel Dos Reis <[EMAIL PROTECTED]> | >> I don't understand what you mean here. Are you seriously suggesting | >> that | >> | >> int main(void) { | >> const int x = 4; | >> *(int*)

Re: volatile semantics

2005-07-18 Thread Gabriel Dos Reis
Paul Schlie <[EMAIL PROTECTED]> writes: [...] | > | With all due respect, unless there is an explicit reference in the standard | > | to contradict it's clearly stated requirement that an object's qualified | > | lvalue ("locator value") designates the object being referenced, all | > | interpr

Re: volatile semantics

2005-07-18 Thread Paul Schlie
> From: Paul Schlie <[EMAIL PROTECTED]> >> From: Gabriel Dos Reis <[EMAIL PROTECTED]> >> I don't understand what you mean here. Are you seriously suggesting >> that >> >> int main(void) { >> const int x = 4; >> *(int*)&x = 3; >> } >> >> is well-defined? > > Actually y

Re: volatile semantics

2005-07-18 Thread Paolo Bonzini
- The assignment reference to x is valid as it's not specified as const, therefore must be performed, unless: You simply got the purpose of optimization and, to some extent, high-level languages wrong. This thread shows that if people are reasonable (on both sides) a solution will be found.

Re: volatile semantics

2005-07-18 Thread Jonathan Wakely
On Sun, Jul 17, 2005 at 09:29:11PM -0400, Paul Schlie wrote: > > Note that I'm explicitly not taking a position on what the standard says. > > The standard is notoriously incomplete with respect to object model issues, > > including volatility, so I think that trying particularly hard to parse its

Re: volatile semantics

2005-07-18 Thread Paul Schlie
> From: Gabriel Dos Reis <[EMAIL PROTECTED]> > | Paul Schlie <[EMAIL PROTECTED]> writes: > | > Note that I'm explicitly not taking a position on what the standard says. > | > The standard is notoriously incomplete with respect to object model > | > issues, including volatility, so I think that tryi

Re: volatile semantics

2005-07-17 Thread Gabriel Dos Reis
Paul Schlie <[EMAIL PROTECTED]> writes: | > Note that I'm explicitly not taking a position on what the standard says. | > The standard is notoriously incomplete with respect to object model issues, | > including volatility, so I think that trying particularly hard to parse its | > words in this ar

Re: volatile semantics

2005-07-17 Thread Paul Schlie
> Note that I'm explicitly not taking a position on what the standard says. > The standard is notoriously incomplete with respect to object model issues, > including volatility, so I think that trying particularly hard to parse its > words in this area is probably not a good use of time for people

Re: volatile semantics

2005-07-17 Thread Mark Mitchell
Daniel Berlin wrote: On Sun, 2005-07-17 at 05:13 +0200, Gabriel Dos Reis wrote: Daniel Berlin <[EMAIL PROTECTED]> writes: [...] | > I think that is urgent. | No offense, but everyone thinks the problems that affect them are the | most urgent. miscompilation of KDE was declared urgent; I ho

Re: volatile semantics

2005-07-17 Thread Paul Schlie
> I did see Ian's summary, > > http://gcc.gnu.org/ml/gcc/2005-07/msg00714.html > > wherein he ascribed the semantics of the volatile qualifier to the > access, and not to the object. I agree with his description completely, > as I believe it embodies the intuition that C programmers have used > w

Re: volatile semantics

2005-07-17 Thread Gabriel Dos Reis
Richard Henderson <[EMAIL PROTECTED]> writes: | On Sun, Jul 17, 2005 at 05:03:55PM +0100, Nathan Sidwell wrote: | > Issue 1. | > void Foo (char *ptr) { | > *(volatile char *)ptr; | > } | ... | > char c; | > *(volatile char *)&c; // can this read be deleted? | ... | > void Foo (volatile char *ptr

Re: volatile semantics

2005-07-17 Thread Richard Henderson
On Sun, Jul 17, 2005 at 09:18:01AM -0700, Ian Lance Taylor wrote: > This is PR 22278. DannyB posted a simple, untested, patch here: > http://gcc.gnu.org/ml/gcc/2005-07/msg00699.html Thanks. I think Danny's patch attacks this too late. The following patch appears to do the right thing with

Re: volatile semantics

2005-07-17 Thread Ian Lance Taylor
Richard Henderson <[EMAIL PROTECTED]> writes: > I've got no interest in reading a thread with 250 messages wherein > language lawyers battle it out in a no-holds-barred grudge match. > Would someone like to summarize, preferably with a test case that > one side assumes to be miscompiled? As I rea

Re: volatile semantics

2005-07-17 Thread Richard Henderson
On Sun, Jul 17, 2005 at 05:03:55PM +0100, Nathan Sidwell wrote: > Issue 1. > void Foo (char *ptr) { > *(volatile char *)ptr; > } ... > char c; > *(volatile char *)&c; // can this read be deleted? ... > void Foo (volatile char *ptr) { > *(char *)ptr; I did see Ian's summary, http://gcc.gnu.o

Re: volatile semantics

2005-07-17 Thread Falk Hueffner
Richard Henderson <[EMAIL PROTECTED]> writes: > I've got no interest in reading a thread with 250 messages wherein > language lawyers battle it out in a no-holds-barred grudge match. > Would someone like to summarize, preferably with a test case that > one side assumes to be miscompiled? Case 1:

Re: volatile semantics

2005-07-17 Thread Nathan Sidwell
Richard Henderson wrote: > I've got no interest in reading a thread with 250 messages wherein > language lawyers battle it out in a no-holds-barred grudge match. yeah, I can understand that :) > Would someone like to summarize, preferably with a test case that > one side assumes to be miscompiled?

Re: volatile semantics

2005-07-17 Thread Richard Henderson
I've got no interest in reading a thread with 250 messages wherein language lawyers battle it out in a no-holds-barred grudge match. Would someone like to summarize, preferably with a test case that one side assumes to be miscompiled? Speaking with the optimizer hat on, we *don't* do much optimiza

Re: volatile semantics

2005-07-17 Thread Michael Veksler
Daniel Berlin <[EMAIL PROTECTED]> wrote on 17/07/2005 17:33:17: > On Sun, 2005-07-17 at 08:18 +0300, Michael Veksler wrote: [...] > > I can't agree with that as is. I would refine it to: > > Anything that *does* optimizes away visible reads or writes of > > something marked volatile is bugg

Re: volatile semantics

2005-07-17 Thread Daniel Berlin
On Sun, 2005-07-17 at 08:18 +0300, Michael Veksler wrote: > > > > Gabriel Dos Reis wrote on 17/07/2005 06:07:29: > > > Daniel Berlin <[EMAIL PROTECTED]> writes: > > > > | Anything it sees anything in a statement with volatile, it marks the > > | statement as volatile, which should stop things f

Re: volatile semantics

2005-07-17 Thread Joseph S. Myers
On Sun, 17 Jul 2005, Gabriel Dos Reis wrote: > "D. Hugh Redelmeier" <[EMAIL PROTECTED]> writes: > > | | From: Gabriel Dos Reis <[EMAIL PROTECTED]> > | > | | After many exchanges via private mails and > | | looking at the various reports related to this issue, it has become > | | clear to me tha

Re: volatile semantics

2005-07-17 Thread Gabriel Dos Reis
Andrew Haley <[EMAIL PROTECTED]> writes: [...] | You know, the more this goes on the more I believe we should send | X3J11 a request for clarification. Perhaps X3J11 has been disbanded, | so there may be problems. But we should ask. I don't know whether X3J11 is disbanded. However, at the las

Re: volatile semantics

2005-07-17 Thread Gabriel Dos Reis
"D. Hugh Redelmeier" <[EMAIL PROTECTED]> writes: [...] | | At this point we need: | | (1) agreement from C and C++ maintainers on access through volatile | | lvalue | | I don't know C++ well enough to say whether the analogous optimization | is wrong for C++. C++ has resisted, for two

Re: volatile semantics

2005-07-17 Thread Gabriel Dos Reis
Andrew Pinski <[EMAIL PROTECTED]> writes: | On Jul 16, 2005, at 11:07 PM, Gabriel Dos Reis wrote: | | > | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20222 | > | >Andrew Pinski has declared this to be a bug, but the audit trail | >isn't clear as to why. | | Because the abs is a function

Re: volatile semantics

2005-07-17 Thread Andrew Haley
Gabriel Dos Reis writes: > Daniel Berlin <[EMAIL PROTECTED]> writes: > > | > | There is no point in type qualifiers if they can be simply changed at > | > | will. Do not lie about your objects, and you will not be screwed over. > | > > | > only if the language you're implementing the compi

Re: volatile semantics

2005-07-17 Thread Ian Lance Taylor
Daniel Berlin <[EMAIL PROTECTED]> writes: > > In other words, we're asked to agree that the type of an object > > changes depending on how it is accessed. > > For the benefit of readers, only the first sentence of this para is > > the language of the standard; the rest isn't. > > > > That an ob

Re: volatile semantics

2005-07-17 Thread D. Hugh Redelmeier
| From: Daniel Berlin <[EMAIL PROTECTED]> | On Sat, 2005-07-16 at 21:36 -0400, D. Hugh Redelmeier wrote: | > | From: Gabriel Dos Reis <[EMAIL PROTECTED]> | > | > | After many exchanges via private mails and | > | looking at the various reports related to this issue, it has become | > | clear to

Re: volatile semantics

2005-07-17 Thread Andrew Pinski
On Jul 16, 2005, at 11:07 PM, Gabriel Dos Reis wrote: | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20222 Andrew Pinski has declared this to be a bug, but the audit trail isn't clear as to why. Because the abs is a function call, there is only one load and should be only one load as

Re: volatile semantics

2005-07-17 Thread D. Hugh Redelmeier
| From: Gabriel Dos Reis <[EMAIL PROTECTED]> | | "D. Hugh Redelmeier" <[EMAIL PROTECTED]> writes: | | | | From: Gabriel Dos Reis <[EMAIL PROTECTED]> | | | | | After many exchanges via private mails and | | | looking at the various reports related to this issue, it has become | | | clear to me t

Re: volatile semantics

2005-07-17 Thread Michael Veksler
[EMAIL PROTECTED] wrote on 17/07/2005 08:30:26: > Michael Veksler <[EMAIL PROTECTED]> writes: > > | Gabriel Dos Reis wrote on 17/07/2005 06:07:29: > | > | > Daniel Berlin <[EMAIL PROTECTED]> writes: > | > > | > | Anything it sees anything in a statement with volatile, it marks the > | > | stat

Re: volatile semantics

2005-07-16 Thread Gabriel Dos Reis
Michael Veksler <[EMAIL PROTECTED]> writes: | Gabriel Dos Reis wrote on 17/07/2005 06:07:29: | | > Daniel Berlin <[EMAIL PROTECTED]> writes: | > | > | Anything it sees anything in a statement with volatile, it marks the | > | statement as volatile, which should stop things from touching it | > |

Re: volatile semantics

2005-07-16 Thread Gabriel Dos Reis
"D. Hugh Redelmeier" <[EMAIL PROTECTED]> writes: [...] | If GCC4 causes this much problem with X, I wonder what GCC4 will do to | the Linux kernel. I understand that Linus generally prefers older | GCCs to newer ones. It would be great if his preference were only | superstition. I do not follo

Re: volatile semantics

2005-07-16 Thread Michael Veksler
Gabriel Dos Reis wrote on 17/07/2005 06:07:29: > Daniel Berlin <[EMAIL PROTECTED]> writes: > > | Anything it sees anything in a statement with volatile, it marks the > | statement as volatile, which should stop things from touching it > | (anything that *does* optimize something marked volatil

Re: volatile semantics

2005-07-16 Thread D. Hugh Redelmeier
| From: Gabriel Dos Reis <[EMAIL PROTECTED]> | Daniel Berlin <[EMAIL PROTECTED]> writes: | | [...] | | | > I think that is urgent. | | No offense, but everyone thinks the problems that affect them are the | | most urgent. | | miscompilation of KDE was declared urgent; I hope bug affecting code

Re: volatile semantics

2005-07-16 Thread Michael Veksler
Gabriel Dos Reis wrote on 17/07/2005 06:07:29: > > | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20222 > >Andrew Pinski has declared this to be a bug, but the audit trail >isn't clear as to why. > Maybe because gcc treats -O1 differently from -O2, -O3, and -Os ? Also, since abs is a (b

Re: volatile semantics

2005-07-16 Thread Daniel Berlin
On Sun, 2005-07-17 at 05:13 +0200, Gabriel Dos Reis wrote: > Daniel Berlin <[EMAIL PROTECTED]> writes: > > [...] > > | > I think that is urgent. > | No offense, but everyone thinks the problems that affect them are the > | most urgent. > > miscompilation of KDE was declared urgent; I hope bug a

Re: volatile semantics

2005-07-16 Thread Gabriel Dos Reis
Daniel Berlin <[EMAIL PROTECTED]> writes: [...] | > I think that is urgent. | No offense, but everyone thinks the problems that affect them are the | most urgent. miscompilation of KDE was declared urgent; I hope bug affecting code semantics for X is not just "request for enhancement". -- Gaby

Re: volatile semantics

2005-07-16 Thread Gabriel Dos Reis
Daniel Berlin <[EMAIL PROTECTED]> writes: | Anything it sees anything in a statement with volatile, it marks the | statement as volatile, which should stop things from touching it | (anything that *does* optimize something marked volatile is buggy). great! | I should note that this will probably

Re: volatile semantics

2005-07-16 Thread Daniel Berlin
> At this point we need: > (1) agreement from C and C++ maintainers on access through volatile > lvalue > (2) agreement with the middle-end maintainers not to "optimize" > volatile lvalue expressions We already don't optimize expressions considered to have "volatile" operands. I

Re: volatile semantics

2005-07-16 Thread Daniel Berlin
On Sat, 2005-07-16 at 21:36 -0400, D. Hugh Redelmeier wrote: > | From: Gabriel Dos Reis <[EMAIL PROTECTED]> > > | After many exchanges via private mails and > | looking at the various reports related to this issue, it has become > | clear to me that the interpretations offered to justify why GCC

Re: volatile semantics

2005-07-16 Thread Gabriel Dos Reis
"D. Hugh Redelmeier" <[EMAIL PROTECTED]> writes: | | From: Gabriel Dos Reis <[EMAIL PROTECTED]> | | | After many exchanges via private mails and | | looking at the various reports related to this issue, it has become | | clear to me that the interpretations offered to justify why GCC is | | beha

Re: volatile semantics

2005-07-16 Thread D. Hugh Redelmeier
| From: Gabriel Dos Reis <[EMAIL PROTECTED]> | After many exchanges via private mails and | looking at the various reports related to this issue, it has become | clear to me that the interpretations offered to justify why GCC is | behaving the way it does seem to go beyond what can be inferred.

Re: volatile semantics

2005-07-16 Thread Gabriel Dos Reis
"D. Hugh Redelmeier" <[EMAIL PROTECTED]> writes: | | From: Gabriel Dos Reis <[EMAIL PROTECTED]> | | | The way I see it is that people who designed and wrote the standard | | offer their view and interpretation of of they wrote and some people | | are determined to offer a different interpretation

Re: volatile semantics

2005-07-16 Thread D. Hugh Redelmeier
| From: Gabriel Dos Reis <[EMAIL PROTECTED]> | The way I see it is that people who designed and wrote the standard | offer their view and interpretation of of they wrote and some people | are determined to offer a different interpretation so that they can | claim they are well-founded to apply th

Re: volatile semantics

2005-07-16 Thread Gabriel Dos Reis
Daniel Berlin <[EMAIL PROTECTED]> writes: | On Sun, 2005-07-17 at 00:05 +0200, Gabriel Dos Reis wrote: | > Daniel Berlin <[EMAIL PROTECTED]> writes: | > | > [...] | > | > | You make it sound like the standard is crystal clear on this issue, and | > | everyone who disagrees with your viewpoint a

Re: volatile semantics

2005-07-16 Thread Gabriel Dos Reis
Daniel Berlin <[EMAIL PROTECTED]> writes: | We both know that standards committees are not made up of 1 or 2 people, | and saying "people who designed and wrote the standard offer their view | and interpretation of of they wrote " is not useful when they do not | actually speak for the committee.

Re: volatile semantics

2005-07-16 Thread Daniel Berlin
On Sun, 2005-07-17 at 00:05 +0200, Gabriel Dos Reis wrote: > Daniel Berlin <[EMAIL PROTECTED]> writes: > > [...] > > | You make it sound like the standard is crystal clear on this issue, and > | everyone who disagrees with your viewpoint are just slimeballs trying to > | get around the clear wor

Re: volatile semantics

2005-07-16 Thread Gabriel Dos Reis
Daniel Berlin <[EMAIL PROTECTED]> writes: [...] | You make it sound like the standard is crystal clear on this issue, and | everyone who disagrees with your viewpoint are just slimeballs trying to | get around the clear wording of the standard. I think you're profondly mistaken in your understa

Re: volatile semantics

2005-07-16 Thread Gabriel Dos Reis
Daniel Berlin <[EMAIL PROTECTED]> writes: | On Sat, 2005-07-16 at 23:28 +0200, Gabriel Dos Reis wrote: | > Daniel Berlin <[EMAIL PROTECTED]> writes: | > | > | On Sat, 2005-07-16 at 19:35 +0100, Nathan Sidwell wrote: | > | > Daniel Berlin wrote: | > | > >>> object volatile). | > | > >> | > You don

Re: volatile semantics

2005-07-16 Thread Daniel Berlin
On Sat, 2005-07-16 at 23:28 +0200, Gabriel Dos Reis wrote: > Daniel Berlin <[EMAIL PROTECTED]> writes: > > | On Sat, 2005-07-16 at 19:35 +0100, Nathan Sidwell wrote: > | > Daniel Berlin wrote: > | > >>> object volatile). > | > >> > You don't make people happier by transmutating their programs into

Re: volatile semantics

2005-07-16 Thread Daniel Berlin
On Sat, 2005-07-16 at 23:23 +0200, Gabriel Dos Reis wrote: > Daniel Berlin <[EMAIL PROTECTED]> writes: > > | > | There is no point in type qualifiers if they can be simply changed at > | > | will. Do not lie about your objects, and you will not be screwed over. > | > > | > only if the language y

Re: volatile semantics

2005-07-16 Thread Daniel Berlin
On Sat, 2005-07-16 at 23:23 +0200, Gabriel Dos Reis wrote: > Daniel Berlin <[EMAIL PROTECTED]> writes: > > | > | There is no point in type qualifiers if they can be simply changed at > | > | will. Do not lie about your objects, and you will not be screwed over. > | > > | > only if the language y

Re: volatile semantics

2005-07-16 Thread Gabriel Dos Reis
Daniel Berlin <[EMAIL PROTECTED]> writes: | On Sat, 2005-07-16 at 19:35 +0100, Nathan Sidwell wrote: | > Daniel Berlin wrote: | > >>> object volatile). | > >> | > >> | > >> I don't understand your point. given | > >> void Foo (char const * a) { *(char *)a = 5; } | > >> the compiler generates c

Re: volatile semantics

2005-07-16 Thread Gabriel Dos Reis
Daniel Berlin <[EMAIL PROTECTED]> writes: | > | There is no point in type qualifiers if they can be simply changed at | > | will. Do not lie about your objects, and you will not be screwed over. | > | > only if the language you're implementing the compiler for says so, no | > matter what nifty t

Re: volatile semantics

2005-07-16 Thread Gabriel Dos Reis
Dale Johannesen <[EMAIL PROTECTED]> writes: | > the type of an object | > changes depending on how it is accessed. | | this also makes nonsense of gcc's implementation of type-based aliasing | rules. | |*((int *)&x) = 3 No. That one is specifically covered by the C and C++ standards (alt

Re: volatile semantics

2005-07-16 Thread Gabriel Dos Reis
"D. Hugh Redelmeier" <[EMAIL PROTECTED]> writes: [...] | - let's not talk about "restrict" Oh, it was getting fun :-) -- Gaby

Re: volatile semantics

2005-07-16 Thread Daniel Berlin
> | There is no point in type qualifiers if they can be simply changed at > | will. Do not lie about your objects, and you will not be screwed over. > > only if the language you're implementing the compiler for says so, no > matter what nifty transformation you could have done. > Except that n

Re: volatile semantics

2005-07-16 Thread Gabriel Dos Reis
Daniel Berlin <[EMAIL PROTECTED]> writes: | >> object volatile). | > | > I don't understand your point. given | > void Foo (char const * a) { *(char *)a = 5; } | > the compiler generates code to store 5 through the pointer 'a'. It doesn't turn | > this into a call to 'abort', because it thin

Re: volatile semantics

2005-07-16 Thread Gabriel Dos Reis
Daniel Berlin <[EMAIL PROTECTED]> writes: | On Sat, 2005-07-16 at 12:50 -0400, D. Hugh Redelmeier wrote: | > Sorry for the very late response. It is actually triggered by the | > bugzilla entry | > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22278 | > | > The motivating example, abstracted f

Re: volatile semantics

2005-07-16 Thread Daniel Berlin
On Sat, 2005-07-16 at 19:35 +0100, Nathan Sidwell wrote: > Daniel Berlin wrote: > >>> object volatile). > >> > >> > >> I don't understand your point. given > >> void Foo (char const * a) { *(char *)a = 5; } > >> the compiler generates code to store 5 through the pointer 'a'. It > >> doesn't tu

Re: volatile semantics

2005-07-16 Thread D. Hugh Redelmeier
[I'm just a tourist here. I don't subscribe to the gcc list. I don't hack on gcc itself. I'm just posting because this bug hits me and didn't seem to be analyzed correctly. I have participated in the C standardization process for perhaps 20 years. Now that I look at the GCC list archives, I se

Re: volatile semantics

2005-07-16 Thread Dale Johannesen
On Jul 16, 2005, at 10:34 AM, Andrew Haley wrote: 6.3.2.1: when an object is said to have a particular type, the type is specified by the lvalue used to designate the object. I don't have a standard here, but I will point out that IF this sentence is interpreted to mean the type of an

Re: volatile semantics

2005-07-16 Thread Nathan Sidwell
Daniel Berlin wrote: >>> object volatile). >> >> >> I don't understand your point. given >> void Foo (char const * a) { *(char *)a = 5; } >> the compiler generates code to store 5 through the pointer 'a'. It >> doesn't turn >> this into a call to 'abort', because it thinks you're writing to co

Re: volatile semantics

2005-07-16 Thread Daniel Berlin
> In other words, we're asked to agree that the type of an object > changes depending on how it is accessed. > For the benefit of readers, only the first sentence of this para is > the language of the standard; the rest isn't. > > That an object referred to through a volatile pointer must > "te

Re: volatile semantics

2005-07-16 Thread Andrew Haley
D. Hugh Redelmeier writes: > start of Henry Spencer's comment > > There is little room for compiler writers to maneuver here, unless they > have announced their intentions in advance in their documentation. > Reading C99 carefully: > > ... > > 6.3.2.1: when an object

Re: volatile semantics

2005-07-16 Thread Daniel Berlin
object volatile). I don't understand your point. given void Foo (char const * a) { *(char *)a = 5; } the compiler generates code to store 5 through the pointer 'a'. It doesn't turn this into a call to 'abort', because it thinks you're writing to const storage. Is this *always* the cas

Re: volatile semantics

2005-07-16 Thread Nathan Sidwell
Daniel Berlin wrote: > How does this reasoning not apply to *((char *)a) = 5 where a was > originally of a const qualified type? > Or do you think you can only *add* qualifiers, and not remove them? > > Because if you allow casting away, then you can't ever trust const to be > true either, just l

Re: volatile semantics

2005-07-16 Thread Daniel Berlin
On Sat, 2005-07-16 at 12:50 -0400, D. Hugh Redelmeier wrote: > Sorry for the very late response. It is actually triggered by the > bugzilla entry > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22278 > > The motivating example, abstracted from a misbehaving part of X, is: > void test (c

Re: volatile semantics

2005-07-16 Thread D. Hugh Redelmeier
Sorry for the very late response. It is actually triggered by the bugzilla entry http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22278 The motivating example, abstracted from a misbehaving part of X, is: void test (char *addr) { *((volatile char *) addr); } In

Re: volatile semantics

2005-05-12 Thread Paul Koning
> "Geoffrey" == Geoffrey Keating <[EMAIL PROTECTED]> writes: Geoffrey> Paul Koning <[EMAIL PROTECTED]> writes: >> Still, never mind what the C spec appears to say, optimizing away >> the cast cannot possibly what the user intended. Geoffrey> The user might have written a routine which tak

Re: volatile semantics

2005-05-11 Thread Geoffrey Keating
Paul Koning <[EMAIL PROTECTED]> writes: > Still, never mind what the C spec appears to say, optimizing away the > cast cannot possibly what the user intended. The user might have written a routine which takes a 'volatile int *', with the intent that routine would be used on both regular and volat

Re: volatile semantics

2005-05-05 Thread Paul Schlie
> Dale Johannesen writes: >> Nathan Sidwell wrote: >> Also, I wonder about the following example >> >> int const avail = >> >> int main() { >> while (*(int *)&avail == Foo ()) >>do_something(); >> return 0; >> } >> >> Seeing through the const-stripping cast is a useful optimization. > > It i

Re: volatile semantics

2005-05-05 Thread Dale Johannesen
On May 5, 2005, at 5:23 AM, Kai Henningsen wrote: [EMAIL PROTECTED] (Nathan Sidwell) wrote on 03.05.05 in <[EMAIL PROTECTED]>: Mike Stump wrote: int avail; int main() { while (*(volatile int *)&avail == 0) continue; return 0; } Ok, so, the question is, should gcc produce code that infinit

Re: volatile semantics

2005-05-05 Thread Gabriel Dos Reis
[EMAIL PROTECTED] (Kai Henningsen) writes: | [EMAIL PROTECTED] (Nathan Sidwell) wrote on 03.05.05 in <[EMAIL PROTECTED]>: | | > Mike Stump wrote: | > > int avail; | > > int main() { | > > while (*(volatile int *)&avail == 0) | > > continue; | > > return 0; | > > } | > > | > > | > > Ok, s

Re: volatile semantics

2005-05-05 Thread Paul Koning
> "Kai" == Kai Henningsen <[EMAIL PROTECTED]> writes: Kai> As a QOI issue, it would be nice if such a situation caused a Kai> warning ("ignoring volatile cast ..." or something like that). Kai> It's rather dangerous to have the user believe that this worked Kai> as intended when it didn't

Re: volatile semantics

2005-05-05 Thread Kai Henningsen
[EMAIL PROTECTED] (Nathan Sidwell) wrote on 03.05.05 in <[EMAIL PROTECTED]>: > Mike Stump wrote: > > int avail; > > int main() { > > while (*(volatile int *)&avail == 0) > > continue; > > return 0; > > } > > > > > > Ok, so, the question is, should gcc produce code that infinitely loops,

Re: volatile semantics

2005-05-04 Thread Nathan Sidwell
Dale Johannesen wrote: Both behaviors are standard-compliant. I don't think anyone's disagreeing with that. The point is that the user *requires* a volatile read, but the std *does not* guarantee it. > Treating a reference as volatile when you don't have to just means > strictly following the rule

  1   2   >