473,831 Members | 2,298 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Interpreting error messages (gcc)

I'm wondering if anyone has advice for figuring out error messages
produced by g++. The programs below works fine, until I uncomment out
the two "transform" lines. Then it points me to line 24 (where the
second "bind1st" is) and results in an error message complaining about
no match for 'operator=' and/or problems with 'back_insert_it erator'
(see the entire error message reproduced below). Do I need a cast
somewhere to keep the type-checker happy? Is it a template problem?
Since I'm working with standard containers, I can't imagine that
there's no assignment operator defined. Is there a subtle mistake I've
made, or am I doing something obviously wrong? In addition to figuring
out this particular error, I'd also appreciate general strategies for
figuring out compiler messages produces by g++. Do commercial products
do a better job in the error message department?

Thanks,

Greg Buchholz
#include <list>
#include <string>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <functional>

using namespace std;

list<string> aux(list<string > ps, string n);

int main()
{

list<string> f, out;

f.push_back("fo o");
f.push_back("ba r");
f.push_back("ba z");

list<string> g = bind1st(ptr_fun (*aux),f)("TEST ");

//transform(f.beg in(),f.end(),ba ck_inserter(out ),
// bind1st(ptr_fun (aux),f));

copy(g.begin(), g.end(),ostream _iterator<strin g>(cout, " "));
cout << endl;

return 0;
}

list<string> aux(list<string > ps, string n)
{
list<string> out;
transform(ps.be gin(),ps.end(), back_inserter(o ut),
bind1st(plus<st ring>(),n));
return out;
}
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.2/../../../../include/c++/3.4.2/bits/stl_algo.h:
In function `_OutputIterato r std::transform( _InputIterator,
_InputIterator, _OutputIterator , _UnaryOperation ) [with _InputIterator
=
std::_List_iter ator<std::strin g>, _OutputIterator =
std::back_inser t_iterator<std: :list<std::stri ng,
std::allocator< std::string> > >, _UnaryOperation =
std::binder1st< std::pointer_to _binary_functio n<std::list<std ::string,
std::allocator< std::string> >, std::string, std::list<std:: string,
std::allocator< std::string> > > >]': test3.cpp:24: instantiated from
here
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.2/../../../../include/c++/3.4.2/bits/stl_algo.h:789:
error: no match for 'operator=' in
'(&__result)->std::back_inse rt_iterator<_Co ntainer>::opera tor* [with
_Container = std::list<std:: string, std::allocator< std::string> >]() =
std::binder1st< _Operation>::op erator()(typena me
_Operation::sec ond_argument_ty pe&) const [with _Operation =
std::pointer_to _binary_functio n<std::list<std ::string,
std::allocator< std::string> >, std::string, std::list<std:: string,
std::allocator< std::string> >
](((std::string& )(+(&__first)->std::_List_ite rator<_Tp>::ope rator*

[with _Tp = std::string]())))'
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.2/../../../../include/c++/3.4.2/bits/stl_iterator.h: 363:
note: candidates are: std::back_inser t_iterator<_Con tainer>&
std::back_inser t_iterator<_Con tainer>::operat or=(typename
_Container::con st_reference) [with _Container = std::list<std:: string,
std::allocator< std::string> >]
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.2/../../../../include/c++/3.4.2/bits/stl_iterator.h: 338:
note: std::back_inser t_iterator<std: :list<std::stri ng,
std::allocator< std::string> > >&
std::back_inser t_iterator<std: :list<std::stri ng,
std::allocator< std::string> > >::operator=(co nst
std::back_inser t_iterator<std: :list<std::stri ng,
std::allocator< std::string> > >&)

Jan 24 '06 #1
7 3072
Greg Buchholz wrote:
I'm wondering if anyone has advice for figuring out error messages
produced by g++. The programs below works fine, until I uncomment out
the two "transform" lines. Then it points me to line 24 (where the
second "bind1st" is) and results in an error message complaining about
no match for 'operator=' and/or problems with 'back_insert_it erator'
(see the entire error message reproduced below). Do I need a cast
somewhere to keep the type-checker happy? Is it a template problem?
Since I'm working with standard containers, I can't imagine that
there's no assignment operator defined. Is there a subtle mistake I've
made, or am I doing something obviously wrong? In addition to figuring
out this particular error, I'd also appreciate general strategies for
figuring out compiler messages produces by g++. Do commercial products
do a better job in the error message department?

Thanks,

Greg Buchholz
I'm with you that the error messages involving STL classes can be pretty
hard to parse. The problem in your case is that the function aux
returns a list<string> and your output iterator in transform,
back_inserter(o ut), expects to receive strings. It's writing them
*into* a list of strings, but the things being written need to be strings.

Changing the definition of out to, for example:

list<list<strin g> > out;

will produce compilable code.

-Mark


#include <list>
#include <string>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <functional>

using namespace std;

list<string> aux(list<string > ps, string n);

int main()
{

list<string> f, out;

f.push_back("fo o");
f.push_back("ba r");
f.push_back("ba z");

list<string> g = bind1st(ptr_fun (*aux),f)("TEST ");

//transform(f.beg in(),f.end(),ba ck_inserter(out ),
// bind1st(ptr_fun (aux),f));

copy(g.begin(), g.end(),ostream _iterator<strin g>(cout, " "));
cout << endl;

return 0;
}

list<string> aux(list<string > ps, string n)
{
list<string> out;
transform(ps.be gin(),ps.end(), back_inserter(o ut),
bind1st(plus<st ring>(),n));
return out;
}
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.2/../../../../include/c++/3.4.2/bits/stl_algo.h:
In function `_OutputIterato r std::transform( _InputIterator,
_InputIterator, _OutputIterator , _UnaryOperation ) [with _InputIterator
=
std::_List_iter ator<std::strin g>, _OutputIterator =
std::back_inser t_iterator<std: :list<std::stri ng,
std::allocator< std::string> > >, _UnaryOperation =
std::binder1st< std::pointer_to _binary_functio n<std::list<std ::string,
std::allocator< std::string> >, std::string, std::list<std:: string,
std::allocator< std::string> > > >]': test3.cpp:24: instantiated from
here
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.2/../../../../include/c++/3.4.2/bits/stl_algo.h:789:
error: no match for 'operator=' in
'(&__result)->std::back_inse rt_iterator<_Co ntainer>::opera tor* [with
_Container = std::list<std:: string, std::allocator< std::string> >]() =
std::binder1st< _Operation>::op erator()(typena me
_Operation::sec ond_argument_ty pe&) const [with _Operation =
std::pointer_to _binary_functio n<std::list<std ::string,
std::allocator< std::string> >, std::string, std::list<std:: string,
std::allocator< std::string> >
](((std::string& )(+(&__first)->std::_List_ite rator<_Tp>::ope rator*


[with _Tp = std::string]())))'
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.2/../../../../include/c++/3.4.2/bits/stl_iterator.h: 363:
note: candidates are: std::back_inser t_iterator<_Con tainer>&
std::back_inser t_iterator<_Con tainer>::operat or=(typename
_Container::con st_reference) [with _Container = std::list<std:: string,
std::allocator< std::string> >]
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.2/../../../../include/c++/3.4.2/bits/stl_iterator.h: 338:
note: std::back_inser t_iterator<std: :list<std::stri ng,
std::allocator< std::string> > >&
std::back_inser t_iterator<std: :list<std::stri ng,
std::allocator< std::string> > >::operator=(co nst
std::back_inser t_iterator<std: :list<std::stri ng,
std::allocator< std::string> > >&)

Jan 24 '06 #2
Greg Buchholz wrote:
I'm wondering if anyone has advice for figuring out error messages
produced by g++. [...]


RTFM what 'transform' does. Especially what the predicate is supposed
to do. Try to imagine what "normal" C++ code 'transform' corresponds to.
IOW, try to "unroll" to loop behind it.

V
Jan 24 '06 #3
Mark P wrote:
I'm with you that the error messages involving STL classes can be pretty
hard to parse. The problem in your case is that the function aux
returns a list<string> and your output iterator in transform,
back_inserter(o ut), expects to receive strings. It's writing them
*into* a list of strings, but the things being written need to be strings.

Changing the definition of out to, for example:

list<list<strin g> > out;

will produce compilable code.


Arrrgh, of course. Good catch. But I'm curious, how did you spot
the problem? Did you just glance at the code and recognize the type
error? Or was it your experience that lead you to suspect that
complicated error messages are probably simple type problems? Or did
the actual error message help you out in any way?

Thanks again,

Greg Buchholz

Jan 24 '06 #4
Greg Buchholz wrote:
Mark P wrote:
I'm with you that the error messages involving STL classes can be pretty
hard to parse. The problem in your case is that the function aux
returns a list<string> and your output iterator in transform,
back_inserter(o ut), expects to receive strings. It's writing them
*into* a list of strings, but the things being written need to be strings.

Changing the definition of out to, for example:

list<list<strin g> > out;

will produce compilable code.


Arrrgh, of course. Good catch. But I'm curious, how did you spot
the problem? Did you just glance at the code and recognize the type
error? Or was it your experience that lead you to suspect that
complicated error messages are probably simple type problems? Or did
the actual error message help you out in any way?

Thanks again,

Greg Buchholz


The error message got me to the problematic line but I didn't get far
trying to make sense of the many nested angle brackets. What stuck out
most prominently is that you were using the same back_inserter in two
obviously different contexts-- from there you can see how I came across
the error.
Jan 24 '06 #5
On Tue, 24 Jan 2006 05:36:47 GMT
Mark P <fa******@REMOV Efall2005.CAPSf astmail.fm> wrote:
Greg Buchholz wrote:
Mark P wrote:
I'm with you that the error messages involving STL classes can be
pretty hard to parse. The problem in your case is that the
function aux returns a list<string> and your output iterator in
transform, back_inserter(o ut), expects to receive strings. It's
writing them *into* a list of strings, but the things being
written need to be strings.

Changing the definition of out to, for example:

list<list<strin g> > out;

will produce compilable code.

Arrrgh, of course. Good catch. But I'm curious, how did you
spot the problem? Did you just glance at the code and recognize
the type error? Or was it your experience that lead you to suspect
that complicated error messages are probably simple type problems?
Or did the actual error message help you out in any way?

Thanks again,

Greg Buchholz


The error message got me to the problematic line but I didn't get far
trying to make sense of the many nested angle brackets. What stuck
out most prominently is that you were using the same back_inserter in
two obviously different contexts-- from there you can see how I came
across the error.


And then, now it is quite understandable (ie. you can *quickly* find
the information). I mean, you find very easily the templates involved,
and the arguments follows. Previous versions (and it is also true for
other compilers I used) just gave you the template with all the
arguments between the <> ...

But then for your message, you can find the error here (although your
case is quite complex) :

1) /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.2/../../../../include/c++/3.4.2/bits/stl_algo.h:789:
error: no match for 'operator=' in

2) '(&__result)->std::back_inse rt_iterator<_Co ntainer>::opera tor*

3) [with _Container = std::list<std:: string, std::allocator< std::string>]
3) () = std::binder1st< _Operation>::op erator()(typena me
_Operation::sec ond_argument_ty pe&) const

4) [with _Operation =
std::pointer_to _binary_functio n<std::list<std ::string,
std::allocator< std::string> >, std::string, std::list<std:: string,
std::allocator< std::string> >]


5) (((std::string& )(+(&__first)->std::_List_ite rator<_Tp>::ope rator*
[with _Tp = std::string]())))'

So the first line tells you the operator = *does* exist, but is not
overloaded with the type used here. The following lines correspond to
the expression. Second line gives you the faulty template ... a
back_inserter of some _Container ... here a list of string. Line 3
tells you the problem is when assigning the result of the binder1st.
And, at last, line 4 you have the operation involved and you can see
the return type (i.e. the first argument of the
pointer_to_bina ry_function) is a list of string ... instead of a string.

I may say it takes quite some time to get used to errors with
templates. If I would recommend something : split the important line in
many other lines like I did here, but only if you cannot guess what the
error is just from the first lines (as Mark did).

Pierre

--
FORTUNE PROVIDES QUESTIONS FOR THE GREAT ANSWERS: #21
A: Dr. Livingston I. Presume.
Q: What's Dr. Presume's full name?
Jan 24 '06 #6
Greg Buchholz wrote:
I'm wondering if anyone has advice for figuring out error messages
produced by g++.


STLFilt (http://www.bdsoft.com/tools/stlfilt.html) could help. It's not
g++ specific but simplifies and/or reformats long-winded C++ error and
warning messages, with a focus on STL-related diagnostics.

- Franz

Jan 24 '06 #7
Franz wrote:
Greg Buchholz wrote:
I'm wondering if anyone has advice for figuring out error messages
produced by g++.


STLFilt (http://www.bdsoft.com/tools/stlfilt.html) could help. It's not
g++ specific but simplifies and/or reformats long-winded C++ error and
warning messages, with a focus on STL-related diagnostics.

- Franz


Actually, the gcc-specific version *is* g++ specific ;-)
-leor

Jan 26 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2326
by: r6uji7 | last post by:
hello, i am new to PHP programming and wondered if u could help. lets say i have the following files: 1. error.php: that is routed to for all errors. this page should display proper and explanatory error messages to the user based on the parameter provided. 2. errordef.php: has all the error codes and their explanations
5
1105
by: Patrick Coleman | last post by:
Hi, This may seem to be a basic question, but I keep getting the following error: main.cc:93: undefined reference to `AT_UrlParser::AT_UrlParser(char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)' line 93: AT_UrlParser qservice(service); I'm including a custom header file that defines AT_UrlParser.
11
2352
by: Markus Dehmann | last post by:
I have started with C++ a few months ago. The language itself is nice, but what I really don't like are the error messages that I get from g++. g++ error messages are often just not helpful. Sometimes I just take the line number of the error and try to figure out myself what might be wrong. Or I just remember this error message and know already: if g++ says error X it really means error Y.
7
1671
by: Steven T. Hatton | last post by:
One think I really dislike about the (default?) behavior of gcc is the way it prints errors to console. This is one such report: cd /home/hattons/code/c++/sth/vmath/test/ # -*-compilation-*- Entering directory `/home/hattons/code/c++/sth/vmath/test/' g++ -o testMatrix3 testMatrix3.cc -I/home/hattons/code/c++ In file included from Matrix3Test.hh:4, from testMatrix3.cc:1: /home/hattons/code/c++/sth/vmath/Matrix3.hh:141: error:...
1
2569
by: quigstah | last post by:
Hello Friends, Building my software on a standard Debian sarge 'testing' machine. Builds have been occuring with regular frequency for months without this error cropping up, but I now get a significant number of errors complaining of: `.L1590' referenced in section `.rodata' of ...... which causes the build to exit with Error. My environment is as such:
11
1774
by: Andrew Poelstra | last post by:
I hammered this out this morning to fix inconsistancies with the way my programs handle errors. The code itself is fine, in that it compiles with Richard Heathfield's gcc tags (plus -c because it doesn't have a main). Any comments? /* Start of header */ #ifndef _ERROR_H_ #define _ERROR_H_
6
2274
by: David Mathog | last post by:
Do any of you happen to have links to compendiums (or heaven forbid, an actual manual) which maps compiler warnings and errors to examples of actual code problems? In this case I'm specifically looking for one for gcc. The general problem is of course that the compiler messages must be short, and that tends to make them so cryptic that it isn't always immediately obvious what the problem is. It almost makes me long for the days when the...
2
3535
by: John | last post by:
I'm trying to install matplotlib and currently getting the below error. I searched the group and google and couldn't find anything similar... Any ideas? Thanks in advance! src/ft2font.cpp: In member function 'Py::Object Glyph::get_path(FT_FaceRec_* const&)': src/ft2font.cpp:441: error: 'FT_CURVE_TAG_CUBIC' was not declared in this scope
2
6367
by: akhilesh.noida | last post by:
I am trying to compile glibc-2.5 for ARM based board. But I am getting errors while configuring it. Please check and give your inputs for resolving this. configure command : $ ../glibc-2.5/configure --prefix=/mnt/new/Mars/glibc_HQ_test/GLIBC/ install/ --with-__thread --enable-kernel=2.6.11 --enable-shared
0
9794
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9642
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10538
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7750
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5788
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3077
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.