Message ID | 51ED7013.9040002@oracle.com |
---|---|
State | New |
Headers | show |
OK.
> (*) Note that, depending on how it's called, the predicate can currently produce errors anyway, for example because it calls complete_type. This may or may not be all there is to c++/57942.
It looks like lookup_base seems to deliberately avoid trying to complete
the base, so the call to complete_type is coming from elsewhere.
Jason
On 07/22/2013 09:22 PM, Jason Merrill wrote: > OK. Thanks, applied. >> (*) Note that, depending on how it's called, the predicate can >> currently produce errors anyway, for example because it calls >> complete_type. This may or may not be all there is to c++/57942. > It looks like lookup_base seems to deliberately avoid trying to > complete the base, so the call to complete_type is coming from elsewhere. I see, indeed the comment in lookup_base: /* If BASE is incomplete, it can't be a base of T--and instantiating it might cause an error. */ is very clear. Now, I tell you briefly what is going on: standard_conversion calls ptr_reasonably_similar, which, in turn calls comptypes. The latter, via structural_comptypes, does: if ((strict & COMPARE_BASE) && DERIVED_FROM_P (t1, t2)) break; else if ((strict & COMPARE_DERIVED) && DERIVED_FROM_P (t2, t1)) break; you see, DERIVED_FROM_P, thus lookup_base, handles *both* the pair (base, derived) and the swapped pair (derived, base), thus for sure in one case the above comment / code doesn't help, because it protects vs the instantiation of the base argument not vs the instantiation of the t argument... bummer. I guess fixing the issue must be rather doable but at the moment I'm not clear about where to act... Thanks! Paolo.
I guess ptr_reasonably_similar should return false if one of the target types is incomplete. Jason
Index: cp-tree.h =================================================================== --- cp-tree.h (revision 201122) +++ cp-tree.h (working copy) @@ -1320,8 +1320,7 @@ enum languages { lang_c, lang_cplusplus, lang_java /* Nonzero iff TYPE is derived from PARENT. Ignores accessibility and ambiguity issues. */ #define DERIVED_FROM_P(PARENT, TYPE) \ - (lookup_base ((TYPE), (PARENT), ba_any, NULL, tf_warning_or_error)\ - != NULL_TREE) + (lookup_base ((TYPE), (PARENT), ba_any, NULL, tf_none) != NULL_TREE) /* Gives the visibility specification for a class type. */ #define CLASSTYPE_VISIBILITY(TYPE) \