From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12832 invoked by alias); 2 Jul 2005 17:42:49 -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 12818 invoked by uid 48); 2 Jul 2005 17:42:47 -0000 Date: Sat, 02 Jul 2005 17:42:00 -0000 Message-ID: <20050702174247.12817.qmail@sourceware.org> From: "pinskia at gcc dot gnu dot org" 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/msg00196.txt.bz2 List-Id: ------- Additional Comments From pinskia at gcc dot gnu dot org 2005-07-02 17:42 ------- Since the orginal pointer is not violatile the cast will not change any thing since the compiler can deduce it is not violatile. >>From C99, 5.1.2.3 P3: In the abstract machine, all expressions are evaluated as specified by the semantics. An actual implementation need not evaluate part of an expression if it can deduce that its value is not used and that no needed side effects are produced (including anycaused by calling a function or accessing a volatile object). and since violatile applies the type which is being pointed to and not to the pointer, the compiler can deduce it is not needed. Casting away the violatile in a pointer changes the behavior (just like const). -- What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22278