From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9684 invoked by alias); 3 Jul 2005 04:43:24 -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 9657 invoked by uid 22791); 3 Jul 2005 04:43:19 -0000 Received: from smtp-100-sunday.noc.nerim.net (HELO mallaury.nerim.net) (62.4.17.100) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Sun, 03 Jul 2005 04:43:19 +0000 Received: from uniton.integrable-solutions.net (gdr.net1.nerim.net [62.212.99.186]) by mallaury.nerim.net (Postfix) with ESMTP id 8E9FC4F3AE; Sun, 3 Jul 2005 06:43:14 +0200 (CEST) Received: from uniton.integrable-solutions.net (localhost [127.0.0.1]) by uniton.integrable-solutions.net (8.12.10/8.12.10/SuSE Linux 0.7) with ESMTP id j634gKKY027572; Sun, 3 Jul 2005 06:42:21 +0200 Received: (from gdr@localhost) by uniton.integrable-solutions.net (8.12.10/8.12.10/Submit) id j634gKAY027571; Sun, 3 Jul 2005 06:42:20 +0200 To: gcc-bugzilla@gcc.gnu.org Cc: gcc-bugs@gcc.gnu.org Subject: Re: [Bug c/22278] gcc -O2 discards cast to volatile References: <20050702164323.22278.olivier.baudron@m4x.org> <20050703041424.27151.qmail@sourceware.org> From: Gabriel Dos Reis In-Reply-To: <20050703041424.27151.qmail@sourceware.org> Date: Sun, 03 Jul 2005 04:43:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2005-07/txt/msg00244.txt.bz2 List-Id: "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