From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6306 invoked by alias); 3 Jul 2005 00:03:42 -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 6271 invoked by alias); 3 Jul 2005 00:03:39 -0000 Date: Sun, 03 Jul 2005 00:03:00 -0000 Message-ID: <20050703000339.6270.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/msg00231.txt.bz2 List-Id: ------- Additional Comments From gdr at integrable-solutions dot net 2005-07-03 00:03 ------- Subject: Re: gcc -O2 discards cast to volatile "gcc2eran at tromer dot org" writes: | ------- Additional Comments From gcc2eran at tromer dot org 2005-07-02 23:30 ------- | (In reply to comment #17) | > Furthermore, the fundamental issue is whether this | > | > *(volatile int*) (int*) (&foo); | > | > (or equivalent) where foo has been defined volatile int should be | > treated differently from | > | > *(volatile int*) (&foo); | > | > or | > | > foo; | | How about this? | | int foo; | *(volatile int*) (&foo); It was included in my previous message. | In other words, why should the compiler bother at all with the qualifiers of | what the pointer "really" points to? Because the language definition says that the compiler should preserve a semantics and the compiler better bothers. | It seems simplest and most natural to | decree that any dereference of a pointer-to-volatile (regardless of | its origin) is to be treated as volatile and thus never optimized | away. In other words, "volatile" should treated as a property of the | type of the pointer being dereferenced, not of the actual object | being pointed to. but that is a fundamental departure from the language semantics. Replace "volatile" with "const" -- both are qualifiers -- and observe the disaster that would ensue. The "volatile" cv-qualified is interesting in the sense that it is fuzzily defined, but there are identities that the compiler must preserve. -- Gaby -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22278