* [Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
2011-11-17 9:26 [Bug c++/51188] New: invalid static_cast from type 'XBase' to type 'int' mario-baumann at web dot de
@ 2011-11-17 9:29 ` fabien at gcc dot gnu.org
2011-11-17 10:20 ` fabien at gcc dot gnu.org
` (13 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: fabien at gcc dot gnu.org @ 2011-11-17 9:29 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
2011-11-17 9:26 [Bug c++/51188] New: invalid static_cast from type 'XBase' to type 'int' mario-baumann at web dot de
2011-11-17 9:29 ` [Bug c++/51188] " fabien at gcc dot gnu.org
@ 2011-11-17 10:20 ` fabien at gcc dot gnu.org
2011-11-17 10:43 ` fabien at gcc dot gnu.org
` (12 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: fabien at gcc dot gnu.org @ 2011-11-17 10:20 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
2011-11-17 9:26 [Bug c++/51188] New: invalid static_cast from type 'XBase' to type 'int' mario-baumann at web dot de
2011-11-17 9:29 ` [Bug c++/51188] " fabien at gcc dot gnu.org
2011-11-17 10:20 ` fabien at gcc dot gnu.org
@ 2011-11-17 10:43 ` fabien at gcc dot gnu.org
2011-11-17 15:22 ` jason at gcc dot gnu.org
` (11 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: fabien at gcc dot gnu.org @ 2011-11-17 10:43 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
2011-11-17 9:26 [Bug c++/51188] New: invalid static_cast from type 'XBase' to type 'int' mario-baumann at web dot de
` (2 preceding siblings ...)
2011-11-17 10:43 ` fabien at gcc dot gnu.org
@ 2011-11-17 15:22 ` jason at gcc dot gnu.org
2011-11-17 20:04 ` jason at gcc dot gnu.org
` (10 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-17 15:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51188
--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
2011-11-17 9:26 [Bug c++/51188] New: invalid static_cast from type 'XBase' to type 'int' mario-baumann at web dot de
` (3 preceding siblings ...)
2011-11-17 15:22 ` jason at gcc dot gnu.org
@ 2011-11-17 20:04 ` jason at gcc dot gnu.org
2011-11-17 20:58 ` fabien at gcc dot gnu.org
` (9 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-17 20:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51188
--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 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).
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
2011-11-17 9:26 [Bug c++/51188] New: invalid static_cast from type 'XBase' to type 'int' mario-baumann at web dot de
` (4 preceding siblings ...)
2011-11-17 20:04 ` jason at gcc dot gnu.org
@ 2011-11-17 20:58 ` fabien at gcc dot gnu.org
2011-11-17 21:00 ` fabien at gcc dot gnu.org
` (8 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: fabien at gcc dot gnu.org @ 2011-11-17 20:58 UTC (permalink / raw)
To: gcc-bugs
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;
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
2011-11-17 9:26 [Bug c++/51188] New: invalid static_cast from type 'XBase' to type 'int' mario-baumann at web dot de
` (5 preceding siblings ...)
2011-11-17 20:58 ` fabien at gcc dot gnu.org
@ 2011-11-17 21:00 ` fabien at gcc dot gnu.org
2011-11-17 21:02 ` fabien at gcc dot gnu.org
` (7 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: fabien at gcc dot gnu.org @ 2011-11-17 21:00 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
2011-11-17 9:26 [Bug c++/51188] New: invalid static_cast from type 'XBase' to type 'int' mario-baumann at web dot de
` (6 preceding siblings ...)
2011-11-17 21:00 ` fabien at gcc dot gnu.org
@ 2011-11-17 21:02 ` fabien at gcc dot gnu.org
2011-11-17 21:04 ` fabien at gcc dot gnu.org
` (6 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: fabien at gcc dot gnu.org @ 2011-11-17 21:02 UTC (permalink / raw)
To: gcc-bugs
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. ***
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
2011-11-17 9:26 [Bug c++/51188] New: invalid static_cast from type 'XBase' to type 'int' mario-baumann at web dot de
` (7 preceding siblings ...)
2011-11-17 21:02 ` fabien at gcc dot gnu.org
@ 2011-11-17 21:04 ` fabien at gcc dot gnu.org
2011-11-17 21:06 ` fabien at gcc dot gnu.org
` (5 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: fabien at gcc dot gnu.org @ 2011-11-17 21:04 UTC (permalink / raw)
To: gcc-bugs
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. ***
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
2011-11-17 9:26 [Bug c++/51188] New: invalid static_cast from type 'XBase' to type 'int' mario-baumann at web dot de
` (8 preceding siblings ...)
2011-11-17 21:04 ` fabien at gcc dot gnu.org
@ 2011-11-17 21:06 ` fabien at gcc dot gnu.org
2011-11-17 21:07 ` jason at gcc dot gnu.org
` (4 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: fabien at gcc dot gnu.org @ 2011-11-17 21:06 UTC (permalink / raw)
To: gcc-bugs
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. ***
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
2011-11-17 9:26 [Bug c++/51188] New: invalid static_cast from type 'XBase' to type 'int' mario-baumann at web dot de
` (9 preceding siblings ...)
2011-11-17 21:06 ` fabien at gcc dot gnu.org
@ 2011-11-17 21:07 ` jason at gcc dot gnu.org
2011-11-17 21:09 ` fabien at gcc dot gnu.org
` (3 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-17 21:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51188
--- Comment #12 from Jason Merrill <jason at gcc dot gnu.org> 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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
2011-11-17 9:26 [Bug c++/51188] New: invalid static_cast from type 'XBase' to type 'int' mario-baumann at web dot de
` (10 preceding siblings ...)
2011-11-17 21:07 ` jason at gcc dot gnu.org
@ 2011-11-17 21:09 ` fabien at gcc dot gnu.org
2011-11-17 21:59 ` fabien at gcc dot gnu.org
` (2 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: fabien at gcc dot gnu.org @ 2011-11-17 21:09 UTC (permalink / raw)
To: gcc-bugs
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. ***
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
2011-11-17 9:26 [Bug c++/51188] New: invalid static_cast from type 'XBase' to type 'int' mario-baumann at web dot de
` (11 preceding siblings ...)
2011-11-17 21:09 ` fabien at gcc dot gnu.org
@ 2011-11-17 21:59 ` fabien at gcc dot gnu.org
2011-11-18 21:03 ` fabien at gcc dot gnu.org
2011-11-18 21:12 ` fabien at gcc dot gnu.org
14 siblings, 0 replies; 16+ messages in thread
From: fabien at gcc dot gnu.org @ 2011-11-17 21:59 UTC (permalink / raw)
To: gcc-bugs
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;
}
}
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
2011-11-17 9:26 [Bug c++/51188] New: invalid static_cast from type 'XBase' to type 'int' mario-baumann at web dot de
` (12 preceding siblings ...)
2011-11-17 21:59 ` fabien at gcc dot gnu.org
@ 2011-11-18 21:03 ` fabien at gcc dot gnu.org
2011-11-18 21:12 ` fabien at gcc dot gnu.org
14 siblings, 0 replies; 16+ messages in thread
From: fabien at gcc dot gnu.org @ 2011-11-18 21:03 UTC (permalink / raw)
To: gcc-bugs
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 <fabien@gcc.gnu.org>
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 <fabien@gcc.gnu.org>
PR c++/51188
* search.c (lookup_field_1): Handle USING_DECLs for the storted
case.
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/51188] invalid static_cast from type 'XBase' to type 'int'
2011-11-17 9:26 [Bug c++/51188] New: invalid static_cast from type 'XBase' to type 'int' mario-baumann at web dot de
` (13 preceding siblings ...)
2011-11-18 21:03 ` fabien at gcc dot gnu.org
@ 2011-11-18 21:12 ` fabien at gcc dot gnu.org
14 siblings, 0 replies; 16+ messages in thread
From: fabien at gcc dot gnu.org @ 2011-11-18 21:12 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 16+ messages in thread