Cardinal Peak Partner Ben Mesander writes:
Something must be done about the obtuse error messages issued by the
GCC compiler, particularly when using C++ and STL classes. Take this,
for example, which is the output I got recently after a one-line change:
src/emmserver.cpp:739: error: conversion from
'std::_Rb_tree_iterator<std::pair<const unsigned int, EMMServer::EMM> >'
to non-scalar type 'std::_Rb_tree_iterator<std::pair<const unsigned int,
std::map<short unsigned int, EMMServer::EMMSource, std::less<short
unsigned int>, std::allocator<std::pair<const short unsigned int,
EMMServer::EMMSource> > > > >' requested
src/emmserver.cpp:740: error: no match for 'operator==' in 'j ==
((EMMServer*)this)->EMMServer::mEMMSources. std::map<_Key, _Tp, _Compare,
_Alloc>::end [with _Key = unsigned int, _Tp = EMMServer::EMM, _Compare =
std::less<unsigned int>, _Alloc = std::allocator<std::pair<const unsigned
int, EMMServer::EMM> >]()'
v4/bits/stl_tree.h:210: note: candidates are: bool
std::_Rb_tree_iterator<_Tp>&) const [with _Tp = std::pair<const
unsigned int, std::map<short unsigned int, EMMServer::EMMSource,
std::less<short unsigned int>, std::allocator<std::pair<const short
unsigned int, EMMServer::EMMSource> > > >]
It went on like this for probably 20 more lines of near-gibberish.
Andy Balaam has a humorous blog post where—almost as an aside—he generates a 1950-byte error message from a source program of only 181 bytes.
There is clearly a problem when someone starts an open source project just to post-process compiler error messages
so as to make them readable. I do use STLFilt, and it’s very helpful.
But it’s fixing a problem that shouldn’t exist in the first place,
because our compiler tools should be better at producing useful error
messages that are intelligible by mere mortals.
The problem was brought to the attention
of the GCC development team almost exactly five years ago today.
Unfortunately, they come down on the side of pedantic correctness
instead of producing a tool that might be more useful to their end
As soon as I have a break on my current project, I’m hoping to investigate Clang/LLVM. It’s a new compiler technology, and I’m hopeful because they list expressive diagnostics as one of their goals. However, they do not yet support C++.
Learn more about Cardinal Peak at cardinalpeak.com.