This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49117] New: 4.5 -> 4.6: user-unfriendly change in "invalid conversion" error message
- From: "zeratul976 at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 23 May 2011 00:02:16 +0000
- Subject: [Bug c++/49117] New: 4.5 -> 4.6: user-unfriendly change in "invalid conversion" error message
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49117
Summary: 4.5 -> 4.6: user-unfriendly change in "invalid
conversion" error message
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: zeratul976@hotmail.com
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'