From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10171 invoked by alias); 3 Jul 2005 04:43:32 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 10131 invoked by alias); 3 Jul 2005 04:43:29 -0000 Date: Sun, 03 Jul 2005 04:43:00 -0000 Message-ID: <20050703044329.10129.qmail@sourceware.org> From: "gdr at integrable-solutions dot net" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20050702164323.22278.olivier.baudron@m4x.org> References: <20050702164323.22278.olivier.baudron@m4x.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c/22278] gcc -O2 discards cast to volatile X-Bugzilla-Reason: CC X-SW-Source: 2005-07/txt/msg00245.txt.bz2 List-Id: ------- Additional Comments From gdr at integrable-solutions dot net 2005-07-03 04:43 ------- Subject: Re: gcc -O2 discards cast to volatile "gcc2eran at tromer dot org" writes: | (In reply to comment #30) | > | OK. Then the volatile-stripping direction can be handled arbitrarily. | > | > I do not understand that comment. | | I meant that we were mostly concerned about what the standard says about the | effect of casting (say) int* into volatile int*, but the other directly is | simply undefined. That is what I do not understand. Could you point me to the relevant passage of the C standard? | Still, consider the following variant: | | void quux(int *bar) { | *(volatile int*)bar = 42; | } | | volatile int foo; | quux((int*)&foo); | | This time there is no "attempt [...] to refer to an object defined with a | volatile-qualified type through use of an lvalue with non-volatile-qualified | type". Really? What does quux() does to the object defined through foo then? | So why does gcc 4.0.0 -O3 still optimize away the assignment? And how | would you fix that with an approach that construes the standard to require | following the type of the "real" object? | | Could the standard intend something so convoluted, when the interpretation in | comment 23 makes things perfectly sensible, well-defined and (in principle) easy | to implement? My understanding is that you have gotten everything backwards. -- Gaby -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22278