Archived

This topic is now archived and is closed to further replies.

petewood

Making STL error messages understandable

Recommended Posts

Newbies are often overwhelmed by the enormous and incomprehensible errors that can be reported from making a mistake using STL. I'm sometimes at a loss too but usually have a clue as to what documentation I need to be looking at to work it out. I thought I'd point you in the direction of STLFilt: An STL Error Message Decryptor for C++. You can integrate it into VC++6 and 7 quite easily (it'll work with many other platforms too) If you get a tricky error message you can just hit a button and it strips out all the non-essential stuff which usually isn't the cause of the error. Leor Zolman, who developed it, used it while helping Scott Meyers with the code examples for his book, Effective STL. This tool is helpful for everyone I think. Pete [edited by - petewood on March 30, 2004 4:25:38 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
STL error messages arn''t that bad, the details are there for a reason.

Share this post


Link to post
Share on other sites
Mostly STL errors ar full of redundant information. The first few words are the only important ones. The rest are usually nested templated defintions which can easily run over 255 characters.

-ddn

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
STL error messages arn't that bad, the details are there for a reason.


Can we get rid of anonymous posters? I'd like to have a conversation with someone I know. It will help to develop more of a sense of respect, help us see how people are developing, give us confidence in each others replies and a history together on the site.

Or, would it be possible for a topic starter to choose whether or not anonymous posters are able to post replies to their topic.


#include <map>
#include <string>

int main()
{
using namespace std;

multimap<string, int> mm;
mm.insert(0);

return 0;
}


gives this error message:
error.cpp(16) : error C2664: 'class std::_Tree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > 
const ,int>,struct std::multimap<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<int> >::_Kfn,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >
>,class std::allocator<int> >::iterator __thiscall std::multimap<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<int> >::insert(const struct std::pair<class std::basic_string<char,struct std::
char_traits<char>,class std::allocator<char> > const ,int> &)' : cannot convert parameter 1 from 'const int' to 'const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,int> &' Reason: cannot convert from 'const int' to 'const struct std::
pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,int>' No constructor could take the source type, or constructor overload resolution was ambiguous


In reply to the AP, the details are there because the compiler writers haven't caught up yet with what the pertinent details are that will help people find the cause of the error. They just dump out everything. It is the easiest thing they can do.

[edited by - petewood on March 31, 2004 3:36:07 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by petewood

Can we get rid of anonymous posters? I''d like to have a conversation with someone I know.



You feel you know someone just because they have a board name?

quote:


gives this error message:

error.cpp(16) : error C2664: ''class std::_Tree&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;
const ,int&gt;,struct std::multimap&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,int,struct std::less&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt;,class std::allocator&lt;int&gt; &gt;::_Kfn,struct std::less&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;
&gt;,class std::allocator&lt;int&gt; &gt;::iterator __thiscall std::multimap&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,int,struct std::less&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt;,class std::allocator&lt;int&gt; &gt;::insert(const struct std::pair&lt;class std::basic_string&lt;char,struct std::
char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const ,int&gt; &)'' : cannot convert parameter 1 from ''const int'' to ''const struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const ,int&gt; &'' Reason: cannot convert from ''const int'' to ''const struct std::
pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const ,int&gt;'' No constructor could take the source type, or constructor overload resolution was ambiguous




The error message is simple enough, just ignore the bits you do not need.

cannot convert parameter 1 from ''const int'' to ''const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,int> &'' Reason: cannot convert from ''const int'' to ''const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,int>'' No constructor could take the source type, or constructor overload resolution was ambiguous


Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
quote:
Original post by petewood

Can we get rid of anonymous posters? I'd like to have a conversation with someone I know.



You feel you know someone just because they have a board name?




You've said a lot of stupid things in the past but that beats them all.

quote:
The error message is simple enough, just ignore the bits you do not need.
cannot convert parameter 1 from 'const int' to 'const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,int> &' Reason: cannot convert from 'const int' to 'const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,int>' No constructor could take the source type, or constructor overload resolution was ambiguous



Right...

STLFilt produces this
error.cpp(16) : error C2664: 'iter multimap<string,int>::insert(pair<string,int> &)'
: cannot convert parameter 1 from 'const int' to 'pair<string,int> &'
Reason: cannot convert from 'const int' to 'const pair<string const,int>'
No constructor could take the source type, or constructor overload resolution was ambiguous


[edited by - petewood on March 31, 2004 4:48:01 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
You''ve said a lot of stupid things in the past but that beats them all.



How so?


quote:

STLFilt produces this



Whats the point in it then? doesn''t add anything to the compiler error message. It also takes away information which others may find useful.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
quote:

STLFilt produces this



Whats the point in it then?


Moderators, what should I do about this AP? They''re pretending to not understand why I''ve started this thread and are making out that there is nothing helpful in what I am talking about. They''re being deliberately provocative. I know the general rule is to just ignore them. But the thing is there is a person hiding behind the Anonymous Poster who I want to treat with respect. I don''t like being ignored and I believe in community. I don''t believe in just pretending something isn''t there. I believe in dealing with things.

AP, use STLFilt if you find it helpful. If you don''t then maybe others will. It only filters the error messages if you want it to (by clicking on the button for example). If you want the detail just don''t push the button.

Share this post


Link to post
Share on other sites
I dunno, this is sort of akin to how folks up in arms over Mel Gibson''s movie just help increase his box office numbers...

And I''ll take someone obviously clueless any day over the ones who complain about STLFilt crashing their machines, only to disappear without a trace when I try to track them down in order to get more information so that I might have a chance to help them with their problem... ;-)

Thanks for helping to spread the word.
-leor


--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: Download BD Software''''s free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by petewood
Moderators, what should I do about this AP? They''re pretending to not understand why I''ve started this thread and are making out that there is nothing helpful in what I am talking about. They''re being deliberately provocative. I know the general rule is to just ignore them. But the thing is there is a person hiding behind the Anonymous Poster who I want to treat with respect. I don''t like being ignored and I believe in community. I don''t believe in just pretending something isn''t there. I believe in dealing with things.



Why do you keep talking to moderators in your posts? If you have something to say then message them directly.

It''s not that im pretending not to understand why you started this thread, its that i really don''t understand. If someone had asked for a tool that helps decode STL messages, then i could see the point. But what is the purpose of this thread? To help ''Newbies'' with something that they have not even asked for help with? If everyone posted advice about something that ''Newbies'' would have trouble with then the board would be flooded with 100000s of posts.

If people were really that interested in decoding STL errors, they would search google, we do not need you posting advice that noone has asked for IMHO.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
we do not need you posting advice that noone has asked for IMHO.

That''s a difficult statement for me to understand because I don''t know who it is that you are speaking for when you say ''we'' and where you got the authority to assume that role.

The phrase ''In My Humble Opinion'' (IMHO) would be a helpful phrase if I knew who you were and understood your humble opinion to be often correct and always humble. As it is I can''t really take what you are saying seriously.

Thanks for reading the post though. At least you''ll know about the tool if you need it.

Pete

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
STL error messages arn''t that bad, the details are there for a reason.


To mister AP!

This post was not aimed to you. Even if YOU think it is easy to understand theese messages, most of the beginners just get
confused by them. This post was directed to those that are intimidated by theese error messages. If you would have read
the post you would have realised that. Hence you would have
no need to reply in the first place.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Most beginners do not use templates or the STL.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Most beginners do not use templates or the STL.


What about those who are beginning using the STL?

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Most beginners do not use templates or the STL.
Most beginners try to write their own code which is slower and more error prone than the STL. Then they come here and get told to use the STL by us. Then they get a 2Kb error message and come here to ask what it means. STLFilt removes the last step so they don''t need to post here asking what it means.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
May I speak for all APs in forwarding the motion that the OAP is just being a complete muppet.

Share this post


Link to post
Share on other sites
for the poster that said beginners don''t use STL, you we''re right years ago ... but not anymore ...

Stroustroup''s entire intention is to learn at a higher level, and that means letting people use "string" and "list" and "map" even before they would have any idea how to write them corretly .. hence why even a newbie program would give a cryptic error message for an error using a simple map of strings in a newbie program ...

I personally don''t use the STL filter, but I''m glad it exists, and wish I had it 3 years ago.

Share this post


Link to post
Share on other sites