From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13251 invoked by alias); 24 Sep 2011 16:26:16 -0000 Received: (qmail 13233 invoked by uid 22791); 24 Sep 2011 16:26:12 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mail-svr1.cs.utah.edu (HELO mail-svr1.cs.utah.edu) (155.98.64.241) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 24 Sep 2011 16:25:58 +0000 Received: from mail-svr1.cs.utah.edu (localhost [127.0.0.1]) by mail-svr1.cs.utah.edu (Postfix) with ESMTP id D14376500C5; Sat, 24 Sep 2011 10:25:57 -0600 (MDT) Received: from gamow.cs.utah.edu (gamow.cs.utah.edu [155.98.66.244]) by mail-svr1.cs.utah.edu (Postfix) with ESMTP; Sat, 24 Sep 2011 10:25:57 -0600 (MDT) Date: Sat, 24 Sep 2011 19:38:00 -0000 From: John Regehr To: David Brown cc: gcc@gcc.gnu.org Subject: Re: Volatile qualification on pointer and data In-Reply-To: <4E7DFB31.9010906@westcontrol.com> Message-ID: References: <4E7A3209.10508@gjlay.de> <4E7DFB31.9010906@westcontrol.com> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed 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/msg00280.txt.bz2 > it. And while I think the compiler should be allowed to generate the > optimised code of 4.6 (i.e., the change is not a bug IMHO), I fully > understand the idea of generating the older, slower, but definitely correct > code of 4.5. My understanding is that the standard mandates the old behavior, so 4.6 is in error. > I am still trying to imagine a real-world use-case for declaring an object > "static const" and later accessing it as "volatile". Yeah, it would seem far clearer to declare it as static const volatile in the first place. I've done a bunch of automated testing of GCC's implementation of volatile. None of that testing would have exposed this bug because we only count acceses to objects declared as volatile. I've come to the conclusion that "volatile" is a language design error. It complicates the compiler implementation and has confusing, underspecified semantics. If you want to force a load or store, an explicit function call is a clearer way to do it. John