string's operator == fails for empty string

Samuel Krempp Samuel.Krempp@crans.ens-cachan.fr
Fri Nov 3 22:21:00 GMT 2000


 I noticed that the empty string "" is found equal to any string, when using libstdc++-v2.
When using v3 the behaviour is normal.

#include <string>
#include <iostream>

int main() {
using namespace std;
string nawak="Ce g++ fait n\'importe nawak.";
cerr<<nawak<<" is an empty string : "
    << (nawak=="")<<endl;
}


g++ -v 
Reading specs from /home/krempp/egcs/bin/../lib/gcc-lib/i686-pc-linux-gnu/2.97/specs
Configured with:  --prefix=/home/krempp/egcsv2 --enable-shared
gcc version 2.97 20001103 (experimental)

--> says nawak and "" are equal.

While --enable-libstdcxx-v3  says they differ.

-- 
Sam


More information about the Libstdc++ mailing list