Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

More precise diagnostic error messages with templates?

Compilation errors with templates are often obscure and not easily decipherable unless one is really well versed with templates. Many times an expert programmer might as well be flummoxed by these. I am sure most of us have felt the pinch of it many a times.

As I understand the C++ standard only mandates implementations to provide a diagnostic for an ill-formed program but not how or what diagnostic messages shall be provided.
However, are there any guidelines laid out by the Standards committee to overcome this problem of not easily decipherable diagnostics (especially) in case of templates. Has this ever even come up for a discussion? Also, are the mainstream implementations doing something about or have planned about this issue?

The question is quite open ended for discussion but with the SO C++ community being one of the most active C++ communities I am sure someone somewhere must have at least some idea of this. Also, a few of Standards committee members (I know) actively participate on the C++ tag, I am hoping they might have some information on this if et al.

like image 356
Alok Save Avatar asked May 24 '12 18:05

Alok Save


2 Answers

You're asking two separate questions.

First of all, yes, mainstream implementations are doing something about it. It may not be a top priority for g++ or msvc, but those aren't the only mainstream implementations. It was one of the design goals behind clang (see http://clang.llvm.org/diagnostics.html), and at least at some point Intel listed better template errors as a selling point for ic++ over msvc.

Second, people on the standards committee discussed this in detail, and mostly agreed that concepts were a big part of the answer, which effectively means that it's been put off to the future since concepts were removed from the C++11 standard.

like image 57
abarnert Avatar answered Nov 16 '22 21:11

abarnert


It's definitely a problem, especially when people start doing tricky stuff with metaclasses. The only tool I know of that helps out a little bit is stlfilt, which "simplifies and/or reformats long-winded C++ error and warning messages, with a focus on STL-related diagnostics"

like image 3
Edward Loper Avatar answered Nov 16 '22 20:11

Edward Loper