From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11498 invoked by alias); 9 Mar 2013 01:00:41 -0000 Received: (qmail 11380 invoked by uid 22791); 9 Mar 2013 01:00:39 -0000 X-SWARE-Spam-Status: No, hits=-7.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,KHOP_THREADED,MISSING_HEADERS,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 09 Mar 2013 01:00:31 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2910Uw3015095 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 8 Mar 2013 20:00:31 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r2910DmZ007233; Fri, 8 Mar 2013 20:00:18 -0500 Message-ID: <513A899C.2030800@redhat.com> Date: Sat, 09 Mar 2013 01:00:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130219 Thunderbird/17.0.3 MIME-Version: 1.0 CC: Keith Seitz , GDB Patches Subject: Re: [RFA] "constify" parse_exp_1 References: <51392C56.7040302@redhat.com> <51392F3F.5090102@redhat.com> <51393886.9030602@redhat.com> <5139D92B.5090106@redhat.com> <5139EDDB.8080201@redhat.com> In-Reply-To: <5139EDDB.8080201@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-03/txt/msg00391.txt.bz2 On 03/08/2013 12:27 PM, Pedro Alves wrote: > Do we really need it? Does this: > > - exp = parse_exp_1 (&p, loc->address, > + exp = parse_exp_1 ((const char **) &p, loc->address, > > break strict aliasing rules? Joseph Meyers confirmed this is indeed not valid in C. > BTW, over lunch I just had an epiphany. :-) > This is perfectly fine: > > for (loc = t->base.loc; loc; loc = loc->next) > { > - p = tmp_p; > + const char *q; > + > + q = tmp_p; > - exp = parse_exp_1 (&p, loc->address, > + exp = parse_exp_1 (&q, loc->address, > block_for_pc (loc->address), 1); > + p = (char *) q; > > It's perfectly valid, as we know Q on output must point within > the object/string TMP_P pointed at on entry. > This reads much more intuitively to me, no funny arithmetic, and > gets rid of the aliasing issue with the other suggestion, and > no new function necessary. And confirmed this approach is valid. -- Pedro Alves