This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
4.5 -> 4.6: user-unfriendly change in error message
- From: Nathan Ridge <zeratul976 at hotmail dot com>
- To: GCC Help Mailing List <gcc-help at gcc dot gnu dot org>
- Date: Sun, 15 May 2011 18:07:37 +0000
- Subject: 4.5 -> 4.6: user-unfriendly change in error message
Hello,
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().
What is the rationale for this change?
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,
so the best option would be:
error: could not convert 'vector::const_iterator' to 'vector::iterator'
Thoughts?
Nate.