From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19439 invoked by alias); 3 Jul 2005 05:40:16 -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 19097 invoked by uid 48); 3 Jul 2005 05:40:12 -0000 Date: Sun, 03 Jul 2005 05:40:00 -0000 Message-ID: <20050703054012.19070.qmail@sourceware.org> From: "hugh at mimosa dot com" 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/msg00253.txt.bz2 List-Id: ------- Additional Comments From hugh at mimosa dot com 2005-07-03 05:40 ------- Simple rule about const and volatile qualifiers (not restrict): the program can manipulate pointer values with and without their qualifiers. But when the program accesses an object that is a volatile object (i.e. defined, created, or fundamentally volatile), it must be via a volatile lvalue. And when the program accesses an object that was created const (defined, created, or fundamentally const), then it must not be modifying it. Optimizers must not presume more. Well, there is a tricky rule about aliasing in N1124 section 6.5 (see footnote 74 on page 68), based on the unqualified types. But we're only talking about qualifiers. And another about multiple modifications between sequence points -- again, not relevant here. So I think that gcc4 is wrong for this case: the access should not be optimized out. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22278