From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32365 invoked by alias); 26 Mar 2002 10:46:18 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 32297 invoked by uid 71); 26 Mar 2002 10:46:12 -0000 Resent-Date: 26 Mar 2002 10:46:12 -0000 Resent-Message-ID: <20020326104612.32296.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, Anders Blomdell Received:(qmail 30258 invoked from network); 26 Mar 2002 10:38:51 -0000 Received: from unknown (HELO localhost.localdomain) (130.235.83.106) by sources.redhat.com with SMTP; 26 Mar 2002 10:38:51 -0000 Received: (from andersb@localhost) by localhost.localdomain (8.11.6/8.11.6) id g2QAcn101746; Tue, 26 Mar 2002 11:38:49 +0100 Message-Id:<200203261038.g2QAcn101746@localhost.localdomain> Date: Tue, 26 Mar 2002 02:46:00 -0000 From: Anders Blomdell To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:3.113 Subject: optimization/6059: -fvolatile-global and -fvolatile-static fails to set volatile X-SW-Source: 2002-03/txt/msg00968.txt.bz2 List-Id: >Number: 6059 >Category: optimization >Synopsis: -fvolatile-* doesn't mark variables as volatile >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Tue Mar 26 02:46:10 PST 2002 >Closed-Date: >Last-Modified: >Originator: Anders Blomdell >Release: 3.0.4 >Organization: Department of Automatic Control >Environment: System: Linux aljazari 2.4.13-KURT #2 Thu Nov 8 10:49:33 CET 2001 i686 unknown Architecture: i686 host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: m68k-unknown-elf configured with: ../../../gcc-3.0.4/configure --prefix=/usr/local/packages/cross/m68k-elf --target=m68k-elf --with-newlib : (reconfigured) ../../../gcc-3.0.4/configure --prefix=/usr/local/packages/cross/m68k-elf --target=m68k-elf --with-newlib : (reconfigured) ../../../gcc-3.0.4/configure --with-gcc-version-trigger=/work/aljazari2/andersb/gnu/gcc-3.0.4/gcc/version.c --host=i686-pc-linux-gnu --prefix=/usr/local/packages/cross/m68k-elf --target=m68k-elf --with-newlib --enable-checking=misc,tree,rtl,gc,gcac >Description: -fvolatile-* doesn't have the same effect as declaring a variable as volatile. >How-To-Repeat: Compile this small C program with -O*, where f and g should produce identical code when -fvolatile-* is specified. static int gi; static volatile int vgi; void f() { int i; for (i = 0 ; i < 1000 ; i++) { gi++; } } void vf() { int i; for (i = 0 ; i < 1000 ; i++) { vgi++; } } >Fix: Apply this patch: --- varasm.c~ Sat Sep 22 03:33:20 2001 +++ varasm.c Tue Mar 26 11:26:25 2002 @@ -743,7 +743,10 @@ && TREE_PUBLIC (decl)) || ((flag_volatile_static && TREE_CODE (decl) == VAR_DECL && (TREE_PUBLIC (decl) || TREE_STATIC (decl))))) - TREE_SIDE_EFFECTS (decl) = 1; + { + TREE_SIDE_EFFECTS (decl) = 1; + TREE_THIS_VOLATILE(decl) = 1; + } SET_DECL_RTL (decl, gen_rtx_MEM (DECL_MODE (decl), gen_rtx_SYMBOL_REF (Pmode, name))); >Release-Note: >Audit-Trail: >Unformatted: