From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9646 invoked by alias); 2 Jul 2005 16:43:31 -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 9607 invoked by uid 48); 2 Jul 2005 16:43:24 -0000 Date: Sat, 02 Jul 2005 16:43:00 -0000 From: "olivier dot baudron at m4x dot org" To: gcc-bugs@gcc.gnu.org Message-ID: <20050702164323.22278.olivier.baudron@m4x.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c/22278] New: gcc -O2 discards cast to volatile X-Bugzilla-Reason: CC X-SW-Source: 2005-07/txt/msg00176.txt.bz2 List-Id: In the following testcase, a read memory access should be made. However gcc -O2 optimizes away the code inside the test function. ------------------- test.c -------------------- void test (char *addr) { *((volatile char *) addr); } ----------------------------------------------- $ gcc -Wall -O2 -S test.c ------------------- test.s -------------------- test.s: .file "test.c" .text .p2align 4,,15 .globl test .type test, @function test: pushl %ebp movl %esp, %ebp popl %ebp ret .size test, .-test .ident "GCC: (GNU) 4.1.0 20050702 (experimental)" .section .note.GNU-stack,"",@progbits ----------------------------------------------- -- Summary: gcc -O2 discards cast to volatile Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: olivier dot baudron at m4x dot org CC: gcc-bugs at gcc dot gnu dot org GCC host triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22278