From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30730 invoked by alias); 18 Jun 2008 01:44:39 -0000 Received: (qmail 30722 invoked by uid 22791); 18 Jun 2008 01:44:39 -0000 X-Spam-Check-By: sourceware.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (140.186.70.10) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 18 Jun 2008 01:44:10 +0000 Received: from mail.gnu.org ([199.232.76.166]:58163 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1K8mgP-0003pr-Ta for gcc@gnu.org; Tue, 17 Jun 2008 21:41:57 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1K8miT-0002vF-PV for gcc@gnu.org; Tue, 17 Jun 2008 21:44:07 -0400 Received: from synapse.neuralscape.com ([198.144.200.82]:42664 helo=neuralscape.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K8miT-0002uF-Al for gcc@gnu.org; Tue, 17 Jun 2008 21:44:05 -0400 Received: from localhost.neuralscape.com ([127.0.0.1] helo=synapse.neuralscape.com) by neuralscape.com with esmtp (Exim 4.42) id 1K8miQ-0006o8-7n; Tue, 17 Jun 2008 18:44:02 -0700 Received: (from shaeffer@localhost) by synapse.neuralscape.com (8.13.8/8.13.8/Submit) id m5I1i1iZ026171; Tue, 17 Jun 2008 18:44:01 -0700 Date: Wed, 18 Jun 2008 01:44:00 -0000 From: Karen Shaeffer To: Ian Lance Taylor Cc: gcc@gnu.org Subject: Re: auto const ints and pointer issue Message-ID: <20080618014401.GA25773@synapse.neuralscape.com> References: <20080617174222.GA19409@synapse.neuralscape.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.2i X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. 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: 2008-06/txt/msg00380.txt.bz2 On Tue, Jun 17, 2008 at 11:01:31AM -0700, Ian Lance Taylor wrote: > > ~~~~~~~~~~~~~~~~ output ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > $ const_ints > > const int ic = 0 *cip = 5 *ip = 5 > > &ic = 0xbfbd72a0 cip = 0xbfbd72a0 ip = 0xbfbd72a0 > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > The global variable code would segfault, as I expected. But the > > auto variable code gives this illogical result. I would appreciate > > comments. I am not on this list, so please ensure I am cc'd with > > any responses. I'll be happy to file a bug, if it is a bug. > > Modifying a variable which is declared const is undefined behaviour. > You can not predict what happens. > > Ian Hi Ian, I can appreciate that. My point was the addresses are not valid here. In my opinion, it seems reasonable to limit the undefined behavior to the value of the variable, or to some form of failure and error, up to and including crashing the process. But to implement the code in such a way to let the process proceed without error, and to have incorrect addresses as we see here, seems to be beyond the common sense scope of the bounds of what this assignment's undefined behavior potential effects might be. It is interesting. Thank you for your comment. Thanks, Karen -- Karen Shaeffer Neuralscape, Palo Alto, Ca. 94306 shaeffer@neuralscape.com http://www.neuralscape.com