1

I was trying to compile a short example program ( 134 lines ) making extensive use of templates, and got nothing less than 500 lines of mysterious code really deep inside the template library, which is quite annoying and useless.

My point isn't how to solve this issue (most probably add the appropriate path to the project..), but I had this problem several times already, and so I have rather an open question in mind : is there any way to improve the understandability of template-related warnings ? Do you experience similar issues ? How do you usually solve them ?

6
  • The question is totally unclear. You have some code with some unclear problem. No chances for solutions unless you show some examples explaining what's wrong. Commented Aug 27, 2010 at 9:57
  • 1
    Not unclear to me. There was a similar question on here a couple days ago though. Basically, some filter tools can parse GCC output and simplify some warnings, making various assumptions that are true for typical usage. But, compiler warnings are a very compiler-specific thing, and there's no portable solution. The "Concepts" extensions once planned for C++0x were partly to address this concern, but sadly have been left out due to time/complexity constraints. Hopefully one day... very exciting, ummm... concept. Commented Aug 27, 2010 at 10:01
  • @sharptooth : I am not looking for a solution to my specific problem, but I would like to know if it is a common problem to get unclear compiler warnings related to the use of templates, and if it is possible to fix that (i.e. provide explicit, short message pointing to the wrong snippet of code written by the user) Commented Aug 27, 2010 at 10:03
  • +1: I got to learn something new from this question's response Commented Aug 27, 2010 at 11:50
  • The wrong snippet in code should be pointed to by the topmost instantiated from here line. Sometimes the error/warning should be clear from that, sometimes (e.g boost lambda) it is easier to figure out what is wrong by studying the reference manual very carefully. Commented Aug 27, 2010 at 16:29

1 Answer 1

2

From wikipedia:

Error messages involving templates tend to be very long and difficult to decipher. This problem has been considered so severe that a number of tools have been written which simplify and prettyprint STL-related error messages to make them more comprehensible.

There are tools to improve the understandability of such error messages, most notable stlfilt.

Sign up to request clarification or add additional context in comments.

1 Comment

Also, I think that Clang error messages tend to be clearer because of the use of typedef... but since I got this from the doc, I am yet unsure about its validity.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.