Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750994AbVKIX3W (ORCPT ); Wed, 9 Nov 2005 18:29:22 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750992AbVKIX3W (ORCPT ); Wed, 9 Nov 2005 18:29:22 -0500 Received: from cantor.suse.de ([195.135.220.2]:18393 "EHLO mx1.suse.de") by vger.kernel.org with ESMTP id S1750987AbVKIX3V (ORCPT ); Wed, 9 Nov 2005 18:29:21 -0500 From: Andreas Schwab To: Vadim Lobanov Cc: "linux-os \\(Dick Johnson\\)" , linas , "J.A. Magallon" , Kyle Moffett , Douglas McNaught , Steven Rostedt , linux-kernel@vger.kernel.org Subject: Re: typedefs and structs References: <20051107204136.GG19593@austin.ibm.com> <1131412273.14381.142.camel@localhost.localdomain> <20051108232327.GA19593@austin.ibm.com> <20051109003048.GK19593@austin.ibm.com> <20051109004808.GM19593@austin.ibm.com> <19255C96-8B64-4615-A3A7-9E5A850DE398@mac.com> <20051109111640.757f399a@werewolf.auna.net> <20051109192028.GP19593@austin.ibm.com> X-Yow: If this is the DATING GAME I want to know your FAVORITE PLANET! Do I get th' MICROWAVE MOPED? Date: Thu, 10 Nov 2005 00:29:16 +0100 In-Reply-To: (Vadim Lobanov's message of "Wed, 9 Nov 2005 14:12:38 -0800 (PST)") Message-ID: User-Agent: Gnus/5.110003 (No Gnus v0.3) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 970 Lines: 28 Vadim Lobanov writes: > However, if the code is as follows: > void foo (void) { > int myvar = 0; > printf("%d\n", myvar); > bar(&myvar); > printf("%d\n", myvar); > } > If bar is declared in _another_ file as > void bar (const int * var); > then I think the compiler can validly cache the value of 'myvar' for the > second printf without re-reading it. Correct/incorrect? Incorrect. bar() may cast away const. In C const does not mean readonly. Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, Maxfeldstra?e 5, 90409 N?rnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/