bug in gnu std including <string> & <vector>?

bug in gnu std including <string> & <vector>?

Post by Richard Sperk » Fri, 12 Dec 1997 04:00:00



Hello,

I cannot get this bit of code to compile, it complains about ambiguous
operators.  I am using g++ ver 2.7.2.3, and libg++ ver 27.1.4, on a
Linux box kernel ver 2.0.30.

Am I doing something wrong?  Why are the templates in function.h being
called at all?

-- cut here --
#include <string>
#include <vector>

void main()
{
        string dog = "Dog";
        string cat = "Cat";

        if( dog != cat )
                dog = cat;

Quote:}

-- cut here --

I would really appreciate any help on this.

Sincerly,
Rick Sperko
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]

[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]

 
 
 

bug in gnu std including <string> & <vector>?

Post by Oleg Zablud » Sat, 13 Dec 1997 04:00:00


: Hello,

: I cannot get this bit of code to compile, it complains about ambiguous
: operators.  I am using g++ ver 2.7.2.3, and libg++ ver 27.1.4, on a
: Linux box kernel ver 2.0.30.

: Am I doing something wrong?  

No. Well, except having void main(). g++ just doesn't do overload
resolution of template functions right. You should either reverse
the order of the inclusion, or use <String.h>, or something like
that, to make g++ compile it. egcs-2.90.16 (pre-g++-2.8.0) compiles
this.

: Why are the templates in function.h being
: called at all?

: -- cut here --
: #include <string>
: #include <vector>

: void main()
: {
:         string dog = "Dog";
:         string cat = "Cat";

:         if( dog != cat )
:                 dog = cat;
: }

Oleg.
--
Life is a *ly transmitted, 100% lethal disease.
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your

  comp.std.c++ FAQ: http://www.veryComputer.com/++/faq.html
  Moderation policy: http://www.veryComputer.com/++/policy.html

]

 
 
 

bug in gnu std including <string> & <vector>?

Post by Stefan Rup » Sat, 13 Dec 1997 04:00:00


Good morning,


> I cannot get this bit of code to compile, it complains about ambiguous
> operators.  I am using g++ ver 2.7.2.3, and libg++ ver 27.1.4, on a
> Linux box kernel ver 2.0.30.

RTFFAQ!

The URL http://www.cygnus.com/misc/g++FAQ.html#SEC49 covers exactly
this problem.  As a workaround use

   if ( ! ( dog == cat ) )

instead of

   if ( dog != cat )

BTW: In C++ the main() function has return type int, not void.

Ciao,
     struppi

--

Geodaetisches Institut der RWTH Aachen          +49 241 25209   (privat)
Templergraben 55, D-52062 Aachen, Germany       +49 172 2615235 (D2)
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your

  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html

]

 
 
 

bug in gnu std including <string> & <vector>?

Post by Jason Merril » Sun, 14 Dec 1997 04:00:00



> I cannot get this bit of code to compile, it complains about ambiguous
> operators.  I am using g++ ver 2.7.2.3, and libg++ ver 27.1.4, on a
> Linux box kernel ver 2.0.30.
> Am I doing something wrong?  Why are the templates in function.h being
> called at all?

You aren't.  g++ 2.7.2 doesn't support partial ordering of function
templates, and those two headers don't play well together as a result.
This particular problem is covered in the gnu.g++.help FAQ.

The g++ in egcs-1.0 (http://www.cygnus.com/egcs/) and the
soon-to-be-released gcc-2.8.0 do support partial ordering, and have no
problems with your testcase.

Jason
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your

  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html

]

 
 
 

1. HELP >>>>>>>>>>>>> WINAPI <<<<<<<<<<<<<<<<<

   I need help in writting a vb program that will monitor the message
queue of another aplication that is running along with my program. Itried
to use PeekMessage api function but the help file says that it can only
peek the application's own message queue.  My program is similar in
working with SPY or the SPY++ program. Is there an api function that Ican
use. PLEEEEEEEEEZE help.

2. PC Software/OS Rebuild

3. <<<<<<Programmers Needed>>>>>>>

4. Sorry yet another Inst. & Configuration test question

5. >>>>>>>>> PROBLEM WITH MSICPB.EXE <<<<<<<<<<<<<<<<<

6. problem

7. <<>><><><><><><><><><><>

8. CFP: 2nd International Conference on Cog.Sci

9. <><><> www.FotoCD.net <><><>

10. ************************<<<<<<LOTUS CORP.SUCKS>>>>>*****************

11. >>>>>STUCK<<<<<< How to subclass desktop?

12. >>>>> SoftImage Animator - North West UK <<<<<<