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:
'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> > > > >' requestedsrc/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> >]()' /usr/lib/gcc/powerpc-unknown-linux-gnu/4.1.2/include/g++- v4/bits/stl_tree.h:210: note: candidates are: bool std::_Rb_tree_iterator<_Tp>::operator==(const 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> > > >]
Unfortunately, this jumbled code continued for 20+ more lines.
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 often use STLFilt, and it’s very helpful, however it’s fixing a problem that shouldn’t exist in the first place. Our compiler tools should be better at producing useful error messages that are more readable for us.
This problem was brought to the attention of the GCC development team almost exactly five years ago today. Unfortunately, they’ve chosen the side of pedantic correctness versus producing a tool that could be more useful to their end users.
Next Steps
As soon as I have a break on my current project — I’m planning to investigate Clang/LLVM; a new compiler technology. I’m hopeful because they list expressive diagnostics as one of their goals. However, they do not yet support C++.
Ben Mesander has more than 18 years of experience leading software development teams and implementing software. His strengths include Linux, C, C++, numerical methods, control systems and digital signal processing. His experience includes embedded software, scientific software and enterprise software development environments.