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;