From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16777 invoked by alias); 24 Aug 2012 16:12:53 -0000 Received: (qmail 16750 invoked by uid 22791); 24 Aug 2012 16:12:50 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,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; Fri, 24 Aug 2012 16:12:38 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7OGCbfs023409 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 24 Aug 2012 12:12:37 -0400 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q7OGCaem019143 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 24 Aug 2012 12:12:36 -0400 From: Tom Tromey To: Dimitrios Apostolou Cc: gcc-patches@gcc.gnu.org, Andrey Belevantsev Subject: Re: failed attempt: retain identifier length from frontend to backend References: Date: Fri, 24 Aug 2012 16:12:00 -0000 In-Reply-To: (Dimitrios Apostolou's message of "Mon, 20 Aug 2012 20:03:39 +0300 (EEST)") Message-ID: <87r4qwl157.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2012-08/txt/msg01684.txt.bz2 >>>>> "Dimitris" == Dimitrios Apostolou writes: Dimitris> [...] since I broke things like the static assert in Dimitris> libcpp/identifiers.c, that I don't even understand: Dimitris> /* We don't need a proxy since the hash table's identifier comes first Dimitris> in cpp_hashnode. However, in case this is ever changed, we have a Dimitris> static assertion for it. */ Dimitris> -extern char proxy_assertion_broken[offsetof (struct cpp_hashnode, ident) == 0 ? 1 : -1]; This assertion is because the implementation of cpp_forall_identifiers relies on the layout of cpp_hashnode: void cpp_forall_identifiers (cpp_reader *pfile, cpp_cb cb, void *v) { ht_forall (pfile->hash_table, (ht_cb) cb, v); } The idea is that since the identifier comes first, we can walk the hash table directly using ht_forall, relying on an implicit cast to convert the ht_identifier* to a cpp_hashnode*. This is somewhat bogus -- casts of functions are almost never good. (In gdb at least we tend to be more pedantic about this kind of thing. But this code has been in libcpp a long time...) If the struct were laid out differently, then cpp_forall_identifiers would need an intermediate function to do the conversion and then call 'cb'. Tom