From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8070 invoked by alias); 18 Jun 2008 01:52:46 -0000 Received: (qmail 8060 invoked by uid 22791); 18 Jun 2008 01:52:44 -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:52:23 +0000 Received: from mx10.gnu.org ([199.232.76.166]:59176) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1K8moN-00047V-ER for gcc@gnu.org; Tue, 17 Jun 2008 21:50:11 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1K8mqR-0005Hp-Dx for gcc@gnu.org; Tue, 17 Jun 2008 21:52:21 -0400 Received: from wf-out-1314.google.com ([209.85.200.173]:13554) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K8mqR-0005HH-0N for gcc@gnu.org; Tue, 17 Jun 2008 21:52:19 -0400 Received: by wf-out-1314.google.com with SMTP id 28so33291wfc.24 for ; Tue, 17 Jun 2008 18:52:17 -0700 (PDT) Received: by 10.142.114.15 with SMTP id m15mr3524968wfc.25.1213753937719; Tue, 17 Jun 2008 18:52:17 -0700 (PDT) Received: by 10.142.239.20 with HTTP; Tue, 17 Jun 2008 18:52:17 -0700 (PDT) Message-ID: Date: Wed, 18 Jun 2008 01:52:00 -0000 From: "Andrew Pinski" To: "Karen Shaeffer" Subject: Re: auto const ints and pointer issue Cc: "Ian Lance Taylor" , gcc@gnu.org In-Reply-To: <20080618014401.GA25773@synapse.neuralscape.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080617174222.GA19409@synapse.neuralscape.com> <20080618014401.GA25773@synapse.neuralscape.com> X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) 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: 2008-06/txt/msg00381.txt.bz2 On Tue, Jun 17, 2008 at 9:44 PM, Karen Shaeffer wrote: > 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 >> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~> 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. I don't see the issue with the pointers being the same. I don't see what you are asking to be different. Casting from one pointer type to another is ok. So we can go from: cip = ⁣ ip = (int *)cip; cip = ip; And cip should be the same as &ic at the end of that code sequence. Thanks, Andrew Pinski