From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21471 invoked by alias); 20 Sep 2011 16:36:06 -0000 Received: (qmail 21297 invoked by uid 22791); 20 Sep 2011 16:36:03 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 20 Sep 2011 16:35:45 +0000 Received: from wpaz17.hot.corp.google.com (wpaz17.hot.corp.google.com [172.24.198.81]) by smtp-out.google.com with ESMTP id p8KGZioD024912 for ; Tue, 20 Sep 2011 09:35:44 -0700 Received: from gxk28 (gxk28.prod.google.com [10.202.11.28]) by wpaz17.hot.corp.google.com with ESMTP id p8KGYSDD005778 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Tue, 20 Sep 2011 09:35:43 -0700 Received: by gxk28 with SMTP id 28so573975gxk.41 for ; Tue, 20 Sep 2011 09:35:43 -0700 (PDT) Received: by 10.68.62.105 with SMTP id x9mr6631131pbr.287.1316536543576; Tue, 20 Sep 2011 09:35:43 -0700 (PDT) Received: by 10.68.62.105 with SMTP id x9mr6631125pbr.287.1316536543419; Tue, 20 Sep 2011 09:35:43 -0700 (PDT) Received: from coign.google.com ([2620:0:1000:2301:21c:25ff:fe14:8d86]) by mx.google.com with ESMTPS id ji3sm7464883pbc.2.2011.09.20.09.35.42 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Sep 2011 09:35:42 -0700 (PDT) From: Ian Lance Taylor To: "Paulo J. Matos" Cc: gcc@gcc.gnu.org Subject: Re: Volatile qualification on pointer and data References: Date: Tue, 20 Sep 2011 16:36:00 -0000 In-Reply-To: (Paulo J. Matos's message of "Tue, 20 Sep 2011 17:07:21 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2011-09/txt/msg00197.txt.bz2 "Paulo J. Matos" writes: > The following code: > static const unsigned int foo = 1; > unsigned int test( void ) > { > const volatile unsigned int *bar = &foo; > return ( *bar ); > } > > in GCC45 works as expected: > $test: > ld AL,#foo ;; AL is return register > bra 0,X ;; end function > > in GCC46: > $test: > ld AL,0 > bra 0,X > > This is worrying because qualifying the data as volatile should be > enough to prevent these sort of optimizations. It did until GCC46. I agree that this looks like a bug. Please file a bug report marked as a regression. Ian