This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Degraded C++ error messages.


Gabriel Dos Reis wrote:

...
| > I much prefer the error message that displays expressions (althougth it
| > could be improved), but some people seems to like the "typed" ones --
| > it should be recalled that C++ expressions can not be consistently and
| > accurately captured by types only. I find it quite unreadable.
| | I am sad to hear that you like expressions more - because those are
| definitely less readable.


Are you saying that

troep.cc:6: error: request for member `base' in `*(&std::vector<_Tp,
   _Alloc>::begin() [with _Tp = int, _Alloc =
   std::allocator<int>]())->__gnu_cxx::__normal_iterator<_Iterator,
   _Container>::operator->() const [with _Iterator = int*, _Container =
   std::vector<int, std::allocator<int> >]()', which is of non-aggregate type `
   int'

is more readale than

troep.cc:6: request for member `base' in `*v.vector<int,allocator<int> >::begin()', which is of non-aggregate type `int'

?

(I think quite the opposite is true)

Something can certainly be said for both: I find that the latter is a lot more concise and, in this case, immediately obvious even to a novice to template programming what the problem is. The former is more complete and informative, but the extra detail is, IMO, likely to confuse inexperienced users (especially since the detail involves implementation details).

Incidentally, in the elaborated messages I suggest putting the [with
T = ..., U = ...] bit at the very end of the message, not in the
middle as shown above. As it is, it might be easy to miss the text
that follows the template parameter list.

In any case, the legibility of compiler diagnostics is likely to be
a subjective issue. It would be nice if the text could be customized,
say by allowing users to expand the types in place (for essentially
the latter effect, i.e., without the [with T = ...] bit). It would
also be helpful if it was possible (perhaps as an option controlled
by some mapfile) to substitute typedefs for complicated types, say
std::string instead of the more verbose "std::basic_string<_CharT,
_Traits, _Alloc> [with _CharT = char, _Traits = std::char_traits<char>,
_Alloc = std::allocator< char> >]."

Regards
Martin



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]