https://gcc.gnu.org/bugzilla/show_bug.cgi?id=13979
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |msebor at gcc dot gnu.org Resolution|--- |FIXED Known to fail| |7.0 --- Comment #11 from Martin Sebor <msebor at gcc dot gnu.org> --- The errors printed by today's top of trunk (GCC 7.0) for the test case from comment #9 are below. They seem quite clear, at least as good as if not better than Clang's which prints those below. Resolving as fixed. error: no matching function for call to 'foo' int i = foo( (B*)0 ); ^~~ note: candidate function not viable: no known conversion from 'B *' to 'B *&' for 1st argument $ cat t.C && gcc -S -Wall -Wextra -Wpedantic t.C struct B {}; struct D : B {}; struct X {}; int foo(B*&); int i = foo( (B*)0 ); int j = foo( (D*)0 ); D* pd = 0; int k = foo( pd ); X* px = 0; int l = foo( px );\ t.C:17:19: warning: backslash-newline at end of file int l = foo( px );\ t.C:9:20: error: cannot bind non-const lvalue reference of type ‘B*&’ to an rvalue of type ‘B*’ int i = foo( (B*)0 ); ^ t.C:7:5: note: initializing argument 1 of ‘int foo(B*&)’ int foo(B*&); ^~~ t.C:11:20: error: cannot bind non-const lvalue reference of type ‘B*&’ to an rvalue of type ‘B*’ int j = foo( (D*)0 ); ^ t.C:7:5: note: initializing argument 1 of ‘int foo(B*&)’ int foo(B*&); ^~~ t.C:14:17: error: cannot bind non-const lvalue reference of type ‘B*&’ to an rvalue of type ‘B*’ int k = foo( pd ); ^ t.C:7:5: note: initializing argument 1 of ‘int foo(B*&)’ int foo(B*&); ^~~ t.C:17:17: error: invalid initialization of reference of type ‘B*&’ from expression of type ‘X*’ int l = foo( px );\ ^ t.C:7:5: note: in passing argument 1 of ‘int foo(B*&)’ int foo(B*&); ^~~