From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23429 invoked by alias); 17 Nov 2011 20:25:30 -0000 Received: (qmail 23409 invoked by uid 22791); 17 Nov 2011 20:25:29 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 17 Nov 2011 20:25:16 +0000 From: "fabien at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/51188] invalid static_cast from type 'XBase' to type 'int' Date: Thu, 17 Nov 2011 20:58:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: fabien at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: fabien at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-11/txt/msg01801.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51188 --- Comment #6 from fabien at gcc dot gnu.org 2011-11-17 20:24:56 UTC --- (In reply to comment #5) > It looks like the sorted fields code in lookup_field_1 needs to handle > using_decl like the unsorted fields code does. I think this will also fix > PR51141 (instead of the patch you already posted). Thanks, I'm current testing the below patch: Index: class.c =================================================================== --- class.c (revision 181436) +++ class.c (working copy) @@ -6000,7 +6000,7 @@ finish_struct_1 (tree t) hierarchy), and we want this failure to occur quickly. */ n_fields = count_fields (TYPE_FIELDS (t)); - if (n_fields > 7) + if (n_fields > 0) { struct sorted_fields_type *field_vec = sorted_fields_type_new (n_fields); add_fields_to_record_type (TYPE_FIELDS (t), field_vec, 0); Index: search.c =================================================================== --- search.c (revision 181436) +++ search.c (working copy) @@ -424,8 +424,9 @@ lookup_field_1 (tree type, tree name, bo if (want_type) { do - field = fields[i--]; + field = strip_using_decl (fields[i--]); while (i >= lo && DECL_NAME (fields[i]) == name); + if (TREE_CODE (field) != TYPE_DECL && !DECL_TYPE_TEMPLATE_P (field)) field = NULL_TREE; @@ -433,7 +434,7 @@ lookup_field_1 (tree type, tree name, bo else { do - field = fields[i++]; + field = strip_using_decl (fields[i++]); while (i < hi && DECL_NAME (fields[i]) == name); } return field;