Consider the following fragment of invalid code: struct A { struct B {}; int g(); B f() { return g(); } }; GCC 4.5's error message is "error: conversion from 'int' to non-scalar type 'A::B' requested". GCC 4.6's error message is "error: could not convert 'A::g()' to 'A::B'". The 4.6 error message no longer mentions the actual type, int, that cannot be converted to the declared return type, insteading mentioning the expression yielding that type, A::g(). I think 4.5's error message is more useful because you can see from it exactly what conversion (int to A::B) is failing. With 4.6's error message, to find out why the conversion is failing you now have to look up the return value of A::g() in your code. The difference becomes more pronounced with more complex examples. For example, for the code in PR 49003, GCC 4.5: "error: conversion from 'vector::const_iterator' to non-scalar type 'vector::iterator' requested" GCC 4.6: "error: could not convert '((const block*)this)->block::v.vector::begin()' to 'vector::iterator'" Quite clearly, the 4.5 error message is better. Having said that, I think the phrasing of the 4.6 error is better. I think for 4.7, the error message should keep the 4.6 phrasing, but go back to the 4.5 way of mentioning the type being converted from. For example: error: could not convert 'int' to 'A::B'". or: error: could not convert 'vector::const_iterator' to 'vector::iterator'
Author: jason Date: Tue Jun 14 18:16:06 2011 New Revision: 175044 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175044 Log: PR c++/49117 * call.c (perform_implicit_conversion_flags): Print source type as well as expression. Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/call.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/other/error23.C trunk/gcc/testsuite/g++.dg/other/error32.C
Author: jason Date: Tue Jun 14 22:13:36 2011 New Revision: 175060 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175060 Log: PR c++/49117 * call.c (perform_implicit_conversion_flags): Print source type as well as expression. Modified: branches/gcc-4_6-branch/gcc/cp/ChangeLog branches/gcc-4_6-branch/gcc/cp/call.c branches/gcc-4_6-branch/gcc/testsuite/ChangeLog branches/gcc-4_6-branch/gcc/testsuite/g++.dg/other/error23.C branches/gcc-4_6-branch/gcc/testsuite/g++.dg/other/error32.C
Fixed for 4.6.1.