puzzling error from GCC 3.4.4

Discussion in 'C++' started by drn@nadler.com, Oct 7, 2007.

  1. Guest

    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>::eek: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>::eek: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>::eek:perator>>(std::ios_base&(*)(std::ios_base&)) [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>::eek: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>::eek: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>::eek: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>::eek: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>::eek: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>::eek: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>::eek: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>::eek: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>::eek: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>::eek: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>::eek: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>::eek: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>::eek: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>::eek: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::eek: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::eek: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::eek: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::eek: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::eek: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::eek: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::eek: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::eek: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::eek:perator>>(std::basic_istream<char, _Traits>&, unsigned char&)
    [with _Traits = std::char_traits<char>]
    , Oct 7, 2007
    #1
    1. Advertising

  2. Ole Nielsby Guest

    <> 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.
    Ole Nielsby, Oct 7, 2007
    #2
    1. Advertising

  3. 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 ?
    Gianni Mariani, Oct 7, 2007
    #3
  4. Old Wolf Guest

    On Oct 8, 10:49 am, Gianni Mariani <> 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.
    Old Wolf, Oct 8, 2007
    #4
  5. James Kanze Guest

    On Oct 7, 11:49 pm, Gianni Mariani <> wrote:
    > 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::eek: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:
    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
    James Kanze, Oct 8, 2007
    #5
  6. Guest

    On Oct 7, 5:49 pm, Gianni Mariani <> wrote:
    > 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
    , Oct 8, 2007
    #6
  7. Guest

    On Oct 7, 2:34 pm, "Ole Nielsby" <ole.niel...@tekare-you-
    spamminglogisk.dk> wrote:
    > <> 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
    , Oct 8, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roedy Green

    Puzzling JNI error message

    Roedy Green, Sep 23, 2008, in forum: Java
    Replies:
    9
    Views:
    1,874
    Arne Vajhøj
    Oct 12, 2008
  2. Bill Cunningham

    puzzling error

    Bill Cunningham, May 5, 2011, in forum: C Programming
    Replies:
    49
    Views:
    1,167
    Bill Cunningham
    May 11, 2011
  3. Ted
    Replies:
    0
    Views:
    95
  4. Steven D'Aprano

    Re: Puzzling error msg.

    Steven D'Aprano, Dec 3, 2012, in forum: Python
    Replies:
    0
    Views:
    167
    Steven D'Aprano
    Dec 3, 2012
  5. Ian Kelly

    Re: Puzzling error msg.

    Ian Kelly, Dec 3, 2012, in forum: Python
    Replies:
    0
    Views:
    201
    Ian Kelly
    Dec 3, 2012
Loading...

Share This Page