Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > puzzling error from GCC 3.4.4

Reply
Thread Tools

puzzling error from GCC 3.4.4

 
 
drn@nadler.com
Guest
Posts: n/a
 
      10-07-2007
I'm porting some legacy code from BC++5.01 to GCC C++.
I'm a bit baffled - why does GCC produce the errors below using a
temporary in the line:
istrstream( argv[2] /*"49:59.067 N 011:38.317 E"*/ ) >>
mapReferencePoint;
No complaints when its split into two lines as follows:
istrstream is( argv[2] /*"49:59.067 N 011:38.317 E"*/ );
is >> mapReferencePoint;

Thanks in advance for any help !
Best Regards, Dave

The correct match below is:
parsTool.hpp:165: note: std::istream& operator>>(std::istream&,
NavLatLongPoint&)

$ gcc -v
Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: /usr/build/package/orig/test.respin/gcc-3.4.4-3/
configure --ver
bose --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/
lib --libe
xecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --
enable-langu
ages=c,ada,c++,d,f77,pascal,java,objc --enable-nls --without-included-
gettext --
enable-version-specific-runtime-libs --without-x --enable-libgcj --
disable-java-
awt --with-system-zlib --enable-interpreter --disable-libgcj-debug --
enable-thre
ads=posix --enable-java-gc=boehm --disable-win32-registry --enable-
sjlj-exceptio
ns --enable-hash-synchronization --enable-libstdcxx-debug
Thread model: posix
gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)

Error output:

airparse.cpp: In function `int main(int, char**)':
airparse.cpp:680: error: no match for 'operator>>' in
'istrstream((*(argv + 8u))) >> mapReferencePoint'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/istream.tcc:87:
note: candidates are: std::basic_istream<_CharT, _Traits>&
std::basic_istream<_CharT,
_Traits>:perator>>(std::basic_istream<_CharT, _Traits>&(*)
(std::basic_istream<_CharT, _Traits>&)) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/istream.tcc:93:
note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
_Traits>:perator>>(std::basic_ios<_CharT, _Traits>&(*)
(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/istream.tcc:102:
note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
_Traits>:perator>>(std::ios_base&(*)(std::ios_ba se&)) [with _CharT =
char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/istream.tcc:111:
note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
_Traits>:perator>>(bool&) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/istream.tcc:133:
note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
_Traits>:perator>>(short int&) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/istream.tcc:164:
note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
_Traits>:perator>>(short unsigned int&) [with _CharT = char, _Traits
= std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/istream.tcc:186:
note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
_Traits>:perator>>(int&) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/istream.tcc:217:
note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
_Traits>:perator>>(unsigned int&) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/istream.tcc:239:
note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
_Traits>:perator>>(long int&) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/istream.tcc:261:
note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
_Traits>:perator>>(long unsigned int&) [with _CharT = char, _Traits
= std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/istream.tcc:284:
note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
_Traits>:perator>>(long long int&) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/istream.tcc:306:
note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
_Traits>:perator>>(long long unsigned int&) [with _CharT = char,
_Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/istream.tcc:329:
note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
_Traits>:perator>>(float&) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/istream.tcc:351:
note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
_Traits>:perator>>(double&) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/istream.tcc:373:
note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
_Traits>:perator>>(long double&) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/istream.tcc:395:
note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
_Traits>:perator>>(void*&) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/istream.tcc:417:
note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
_Traits>:perator>>(std::basic_streambuf<_CharT, _Traits>*) [with
_CharT = char, _Traits = std::char_traits<char>]
parsTool.hpp:131: note: std::istream& operator>>(std::istream&,
LatitudeT&)
parsTool.hpp:136: note: std::istream& operator>>(std::istream&,
LongitudeT&)
parsTool.hpp:165: note: std::istream& operator>>(std::istream&,
NavLatLongPoint&)
airparse.cpp:174: note: std::istream& operator>>(std::istream&,
TNPAltitude&)
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/iomanip:253: note:
std::basic_istream<_CharT, _Traits>&
std:perator>>(std::basic_istream<_CharT, _Traits>&, std::_Setw)
[with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/iomanip:219: note:
std::basic_istream<_CharT, _Traits>&
std:perator>>(std::basic_istream<_CharT, _Traits>&,
std::_Setprecision) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/iomanip:143: note:
std::basic_istream<_CharT, _Traits>&
std:perator>>(std::basic_istream<_CharT, _Traits>&, std::_Setbase)
[with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/iomanip:108: note:
std::basic_istream<_CharT, _Traits>&
std:perator>>(std::basic_istream<_CharT, _Traits>&,
std::_Setiosflags) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/iomanip:74: note:
std::basic_istream<_CharT, _Traits>&
std:perator>>(std::basic_istream<_CharT, _Traits>&,
std::_Resetiosflags) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/istream:692: note:
std::basic_istream<char, _Traits>&
std:perator>>(std::basic_istream<char, _Traits>&, signed char*)
[with _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/istream:687: note:
std::basic_istream<char, _Traits>&
std:perator>>(std::basic_istream<char, _Traits>&, unsigned char*)
[with _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/istream:651: note:
std::basic_istream<char, _Traits>&
std:perator>>(std::basic_istream<char, _Traits>&, signed char&)
[with _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/istream:646: note:
std::basic_istream<char, _Traits>&
std:perator>>(std::basic_istream<char, _Traits>&, unsigned char&)
[with _Traits = std::char_traits<char>]

 
Reply With Quote
 
 
 
 
Ole Nielsby
Guest
Posts: n/a
 
      10-07-2007
<(E-Mail Removed)> wrote:
> I'm porting some legacy code from BC++5.01 to GCC C++.
> I'm a bit baffled - why does GCC produce the errors below using a
> temporary in the line:
> istrstream( argv[2] /*"49:59.067 N 011:38.317 E"*/ ) >>
> mapReferencePoint;
> No complaints when its split into two lines as follows:
> istrstream is( argv[2] /*"49:59.067 N 011:38.317 E"*/ );
> is >> mapReferencePoint;


C++ has a restriction that says, non-const references cannot bind
to temporaries, though many compilers allow it. I think that's what
happens here.


 
Reply With Quote
 
 
 
 
Gianni Mariani
Guest
Posts: n/a
 
      10-07-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I'm porting some legacy code from BC++5.01 to GCC C++.
> I'm a bit baffled - why does GCC produce the errors below using a
> temporary in the line:
> istrstream( argv[2] /*"49:59.067 N 011:38.317 E"*/ ) >>
> mapReferencePoint;
> No complaints when its split into two lines as follows:
> istrstream is( argv[2] /*"49:59.067 N 011:38.317 E"*/ );
> is >> mapReferencePoint;
>


re:
istrstream is( argv[2] /*"49:59.067 N 011:38.317 E"*/ )

a) The standard name is "std::istringstream".

b) The following code compiles.
#include <sstream>
#include <iostream>

int main( int argc, char ** argv)
{
int i;

std::istringstream("10") >> i;
}

So it may be an issue with how you defined your operator >>.

I ran into a number of issues when I placed the operator >> in a
namespace other than "std". This may be a bug with gcc 3.4.4 as I don't
recall running into it with the latest gcc compilers.

What does you declaration for operator>> look like ? Can you give us a
chunk-o-compilable-code ?
 
Reply With Quote
 
Old Wolf
Guest
Posts: n/a
 
      10-07-2007
On Oct 8, 10:49 am, Gianni Mariani <(E-Mail Removed)> wrote:
> istrstream is( argv[2] /*"49:59.067 N 011:38.317 E"*/ )
>
> a) The standard name is "std::istringstream".


istrstream and istringstream are different standard classes.
See D.7.2 [depr.istrstream] in the standard.

 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      10-08-2007
On Oct 7, 11:49 pm, Gianni Mariani <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > I'm porting some legacy code from BC++5.01 to GCC C++.
> > I'm a bit baffled - why does GCC produce the errors below using a
> > temporary in the line:
> > istrstream( argv[2] /*"49:59.067 N 011:38.317 E"*/ ) >>
> > mapReferencePoint;
> > No complaints when its split into two lines as follows:
> > istrstream is( argv[2] /*"49:59.067 N 011:38.317 E"*/ );
> > is >> mapReferencePoint;


> re:
> istrstream is( argv[2] /*"49:59.067 N 011:38.317 E"*/ )


> a) The standard name is "std::istringstream".


Both istrstream and istringstream are defined in the standard.
istrstream has its uses, although I'd probably prefer
istringstream here.

> b) The following code compiles.
> #include <sstream>
> #include <iostream>


> int main( int argc, char ** argv)
> {
> int i;
>
> std::istringstream("10") >> i;
> }


> So it may be an issue with how you defined your operator >>.


Or how the standard requires it to be defined:

int main()
{
std::string s ;
std::istringstream( "10" ) >> s ;
}

doesn't compile. In general, if the operator>> is a member of
istream, it compiles, if the operator>> isn't (and that includes
the operators for all user defined types), it doesn't. (For
output, the behavior is even worse: if there is an implicit
conversion to a type whose << is a member, it is used, and you
output this type.)

The problem is binding a temporary (the istringstream) to a
non-const reference (vs. calling a non-const member function on
a temporary). This is a well known anomaly in the way iostream
works.

> I ran into a number of issues when I placed the operator >> in
> a namespace other than "std".


This depends on what you are outputting, and how you use the
operator. The classic problem here is inputting or outputting a
"standard" type (e.g. std::vector<int>) through a template (e.g.
std::istream_iterator or std:stream_iterator); when
instantiating a template, the compiler only uses argument
dependent lookup for dependent names, so you must have something
in the type you're outputting which uses the namespace where
you've put the operator>>.

The simple answer for this is: don't do it. But while it is the
only correct answer for production code, it is often very
convenient to define an output (or input) operator for something
like std::vector<int> in a small test program. Defining such an
operator yourself in std is formally undefined behavior, but in
practice, for small, throw away test programs, I'll do it.

--
James Kanze (GABI Software) email:(E-Mail Removed)
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

 
Reply With Quote
 
drn@nadler.com
Guest
Posts: n/a
 
      10-08-2007
On Oct 7, 5:49 pm, Gianni Mariani <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > I'm porting some legacy code from BC++5.01 to GCC C++.
> > I'm a bit baffled - why does GCC produce the errors below using a
> > temporary in the line:
> > istrstream( argv[2] /*"49:59.067 N 011:38.317 E"*/ ) >>
> > mapReferencePoint;
> > No complaints when its split into two lines as follows:
> > istrstream is( argv[2] /*"49:59.067 N 011:38.317 E"*/ );
> > is >> mapReferencePoint;

>
> re:
> istrstream is( argv[2] /*"49:59.067 N 011:38.317 E"*/ )
>
> a) The standard name is "std::istringstream".
>
> b) The following code compiles.
> #include <sstream>
> #include <iostream>
>
> int main( int argc, char ** argv)
> {
> int i;
>
> std::istringstream("10") >> i;
>
> }
>
> So it may be an issue with how you defined your operator >>.
>
> I ran into a number of issues when I placed the operator >> in a
> namespace other than "std". This may be a bug with gcc 3.4.4 as I don't
> recall running into it with the latest gcc compilers.
>
> What does you declaration for operator>> look like ? Can you give us a
> chunk-o-compilable-code ?


Hi Gianni - This code uses istrstream specifically.
Yes its deprecated, but as I said in my post this is
port of legacy code...

The >> operator here is used to parse a string
into an application data type. The operator is a
non-class definition relating istrstream to
the app's type.

Thanks though,
Best Regards, Dave

 
Reply With Quote
 
drn@nadler.com
Guest
Posts: n/a
 
      10-08-2007
On Oct 7, 2:34 pm, "Ole Nielsby" <ole.niel...@tekare-you-
spamminglogisk.dk> wrote:
> <(E-Mail Removed)> wrote:
> > I'm porting some legacy code from BC++5.01 to GCC C++.
> > I'm a bit baffled - why does GCC produce the errors below using a
> > temporary in the line:
> > istrstream( argv[2] /*"49:59.067 N 011:38.317 E"*/ ) >>
> > mapReferencePoint;
> > No complaints when its split into two lines as follows:
> > istrstream is( argv[2] /*"49:59.067 N 011:38.317 E"*/ );
> > is >> mapReferencePoint;

>
> C++ has a restriction that says, non-const references cannot bind
> to temporaries, though many compilers allow it. I think that's what
> happens here.


Thanks Ole - That seems to be the problem,
Best Regards, Dave

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Puzzling error msg. Ian Kelly Python 0 12-03-2012 06:27 PM
Re: Puzzling error msg. Steven D'Aprano Python 0 12-03-2012 06:12 PM
puzzling error Bill Cunningham C Programming 49 05-11-2011 06:30 PM
Puzzling JNI error message Roedy Green Java 9 10-12-2008 12:31 AM
puzzling error in script that copies files before processing them Ted Perl Misc 0 07-12-2006 03:25 PM



Advertisments