From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18695 invoked by alias); 25 Sep 2011 14:16:21 -0000 Received: (qmail 18684 invoked by uid 22791); 25 Sep 2011 14:16:20 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mail-out.m-online.net (HELO mail-out.m-online.net) (212.18.0.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 25 Sep 2011 14:16:04 +0000 Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id D994B188A17E; Sun, 25 Sep 2011 16:16:02 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.8.164]) by mail.m-online.net (Postfix) with ESMTP id 9921A1C0006E; Sun, 25 Sep 2011 16:16:02 +0200 (CEST) Received: from mail.mnet-online.de ([192.168.8.180]) by localhost (dynscan1.mail.m-online.net [192.168.8.164]) (amavisd-new, port 10024) with ESMTP id p5KTqLghLBbq; Sun, 25 Sep 2011 16:16:01 +0200 (CEST) Received: from igel.home (ppp-88-217-113-9.dynamic.mnet-online.de [88.217.113.9]) by mail.mnet-online.de (Postfix) with ESMTP; Sun, 25 Sep 2011 16:16:01 +0200 (CEST) Received: by igel.home (Postfix, from userid 501) id 3E217CA296; Sun, 25 Sep 2011 16:16:01 +0200 (CEST) From: Andreas Schwab To: David Brown Cc: gcc@gcc.gnu.org Subject: Re: Volatile qualification on pointer and data References: <4E7A3209.10508@gjlay.de> <4E7DFB31.9010906@westcontrol.com> X-Yow: Yow! I threw up on my window! Date: Sun, 25 Sep 2011 15:15:00 -0000 In-Reply-To: (David Brown's message of "Sun, 25 Sep 2011 14:56:37 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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/msg00288.txt.bz2 David Brown writes: > There is a big difference between defining an object as "const", and > merely declaring it as const or accessing it as const. When you access it > as const, you are saying "/I/ won't change the object with this access". > When you declare an object as const (such as an extern object), you are > saying "/I/ won't change this object". When you /define/ an object as > const, as you do with a "static const", you are saying "this object is > constant. It will never change value - you (the toolchain) can safely > place it in read-only memory that cannot ever change value". You are interpreting too much into const here. The C standard says in footnote 112: "The implementation may place a const object that is not volatile in a read-only region of storage." Note the use of "not volatile". But in any case this is not part of the C standard: it's only a footnote. > And then you make it volatile, telling the compiler "this object might > change unexpectedly, or use values written to it unexpectedly". > > If someone could explain to me how this could have real-world usage, I > think it would be easier for me (and others) to be sure of what it really > means. It's an object that is never written to, but may change unexpectedly. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."