------- Comment #7 from jwakely dot gcc at gmail dot com 2009-08-04 17:48 ------- (In reply to comment #5) > Here's a small testcase: > ---------------- > struct B {}; > struct D : B {}; > > struct S { > int foo(B* & taskData); > }; > > int i = S().foo((D*)0); > -----------------
That tries to initialise a B*& with a D* rvalue, which would fail even if D was the same type as B. This might be a slightly better testcase: struct B {}; struct D : B {}; struct S { int foo(B* & taskData); }; D* p = 0; int i = S().foo(p); It might be an improvement if GCC gave different diagnostics for the case where a suitable conversion sequence exists but cannot be used because it would create an rvalue which cannot bind to a non-const reference, and the case where there is no suitable conversion (i.e. the types are unrelated) That seems to be what 2.95 attempted to do by saying "initializing 'blah' with 'blah' will use a temporary" but I find that message confusing, as it *won't* use a temporary because doing so is not valid. The message should really have been something like "initializing 'blah' with 'blah' would use a temporary, but that's not allowed" -- jwakely dot gcc at gmail dot com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jwakely dot gcc at gmail dot | |com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13979