[Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51188 fabien at gcc dot gnu.org changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution||FIXED --- Comment #15 from fabien at gcc dot gnu.org 2011-11-18 20:36:54 UTC --- Fixed by rev 181490, not 181492.
[Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51188 --- Comment #14 from fabien at gcc dot gnu.org 2011-11-18 20:32:08 UTC --- Author: fabien Date: Fri Nov 18 20:32:04 2011 New Revision: 181492 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181492 Log: gcc/testsuite/ChangeLog 2011-11-18 Fabien Chene PR c++/51188 * g++.dg/lookup/using46.C: New. * g++.dg/lookup/using47.C: New. * g++.dg/lookup/using48.C: New. * g++.dg/lookup/using49.C: New. * g++.dg/lookup/using50.C: New. gcc/cp/ChangeLog 2011-11-18 Fabien Chene PR c++/51188 * search.c (lookup_field_1): Handle USING_DECLs for the storted case. Modified: trunk/gcc/cp/ChangeLog trunk/gcc/testsuite/ChangeLog
[Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51188 --- Comment #13 from fabien at gcc dot gnu.org 2011-11-17 21:53:15 UTC --- (In reply to comment #12) > Let's wait and strip_using_decl after the loop (i.e. at the return statement), > since a USING_DECL has the same name. We also need to check > is_overloaded_decl. Like that ? Index: search.c === --- search.c(revision 181386) +++ search.c(working copy) @@ -436,6 +436,14 @@ lookup_field_1 (tree type, tree name, bo field = fields[i++]; while (i < hi && DECL_NAME (fields[i]) == name); } + + if (field) +{ + field = strip_using_decl (field); + if (is_overloaded_fn (field)) +field = NULL_TREE; +} + return field; } }
[Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51188 fabien at gcc dot gnu.org changed: What|Removed |Added CC||cas43 at cs dot ||stanford.edu --- Comment #10 from fabien at gcc dot gnu.org 2011-11-17 21:00:17 UTC --- *** Bug 51152 has been marked as a duplicate of this bug. ***
[Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51188 --- Comment #12 from Jason Merrill 2011-11-17 21:03:31 UTC --- (In reply to comment #6) >do > -field = fields[i--]; > +field = strip_using_decl (fields[i--]); >while (i >= lo && DECL_NAME (fields[i]) == name); Let's wait and strip_using_decl after the loop (i.e. at the return statement), since a USING_DECL has the same name. We also need to check is_overloaded_decl.
[Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51188 fabien at gcc dot gnu.org changed: What|Removed |Added CC||markus at trippelsdorf dot ||de --- Comment #11 from fabien at gcc dot gnu.org 2011-11-17 21:01:06 UTC --- *** Bug 51141 has been marked as a duplicate of this bug. ***
[Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51188 --- Comment #9 from fabien at gcc dot gnu.org 2011-11-17 20:59:37 UTC --- *** Bug 51189 has been marked as a duplicate of this bug. ***
[Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51188 fabien at gcc dot gnu.org changed: What|Removed |Added CC||reichelt at gcc dot gnu.org --- Comment #8 from fabien at gcc dot gnu.org 2011-11-17 20:58:46 UTC --- *** Bug 51190 has been marked as a duplicate of this bug. ***
[Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51188 --- Comment #7 from fabien at gcc dot gnu.org 2011-11-17 20:57:16 UTC --- FYI, it fixes the following PRs: c++/51190, c++/51189, c++/51188, c++/51152, c++/51141.
[Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
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;
[Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51188 --- Comment #5 from Jason Merrill 2011-11-17 19:32:13 UTC --- 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).
[Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51188 --- Comment #4 from Jason Merrill 2011-11-17 15:17:35 UTC --- (In reply to comment #2) > There is a strange thing here, if we reach 7 members in a class, things are > done differently in the compiler. > > Jason, I'd like to run the testsuite without this 7 member rule, how could I > do > that ? Look for "if (n_fields > 7)" in finish_struct_1.
[Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51188 --- Comment #3 from fabien at gcc dot gnu.org 2011-11-17 10:21:30 UTC --- (In reply to comment #2) > (In reply to comment #0) [...] > Jason, I'd like to run the testsuite without this 7 member rule, how could I > do > that ? To clarify, I mean 0 instead of 7.
[Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51188 fabien at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |ASSIGNED Last reconfirmed||2011-11-17 CC||jason at gcc dot gnu.org Ever Confirmed|0 |1 --- Comment #2 from fabien at gcc dot gnu.org 2011-11-17 09:52:40 UTC --- (In reply to comment #0) [...] > if I remove any of the superfluous statements in x.cpp it works fine! There is a strange thing here, if we reach 7 members in a class, things are done differently in the compiler. Jason, I'd like to run the testsuite without this 7 member rule, how could I do that ? Thanks.
[Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51188 --- Comment #1 from fabien at gcc dot gnu.org 2011-11-17 09:25:55 UTC --- Yet another bug caused by my recent changes with using declarations.