From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 669 invoked by alias); 17 Jun 2008 19:38:55 -0000 Received: (qmail 661 invoked by uid 22791); 17 Jun 2008 19:38:55 -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; Tue, 17 Jun 2008 19:38:27 +0000 Received: from mx10.gnu.org ([199.232.76.166]:44236) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1K8gyV-0000rl-BG for gcc@gnu.org; Tue, 17 Jun 2008 15:36:15 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1K8h0Y-0000zp-V2 for gcc@gnu.org; Tue, 17 Jun 2008 15:38:24 -0400 Received: from synapse.neuralscape.com ([198.144.200.82]:48895 helo=neuralscape.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K8h0Y-0000zV-Fk for gcc@gnu.org; Tue, 17 Jun 2008 15:38:22 -0400 Received: from localhost.neuralscape.com ([127.0.0.1] helo=synapse.neuralscape.com) by neuralscape.com with esmtp (Exim 4.42) id 1K8h0X-0005SR-3M; Tue, 17 Jun 2008 12:38:21 -0700 Received: (from shaeffer@localhost) by synapse.neuralscape.com (8.13.8/8.13.8/Submit) id m5HJcKxV020982; Tue, 17 Jun 2008 12:38:20 -0700 Date: Tue, 17 Jun 2008 19:38:00 -0000 From: Karen Shaeffer To: Ian Lance Taylor Cc: gcc@gnu.org Subject: Re: auto const ints and pointer issue Message-ID: <20080617193820.GA20890@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/msg00377.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 live with that. My problem was that the addresses cannot be correct. In my opinion, the undefined behavior should be limited to the value in the address or in some form of error. But to let the buggy code execute with addresses that are not accurate is a liberty I would hope could have been avoided. It just looks bad. I do realize, no one should have a gripe, because the code is buggy to begin with. But addresses should always be reported accurately IMHO. Of course, I obviously know nothing about compilers. (smiles ;) Thanks for your comments. Karen -- Karen Shaeffer Neuralscape, Palo Alto, Ca. 94306 shaeffer@neuralscape.com http://www.neuralscape.com