I find a BIG bug of VS 2005 about string class!



I find a BIG bug of VS 2005 about string class!

#include <iostream>
#include <string>

using namespace std;

string GetStr()
{
return string("Hello");
}

int main(int argc, char *argv[])
{
const char* p = GetStr().c_str();

cout << p << endl;

cin.get();
}

============================

Run the code above, Dev C++ will normally output the string "Hello",
however, VS 2005 should output an empty string!

In my opinion, string class is vital to almost every C++ program, and
VS 2005 as a C++ compiler is widely used by programmers, if string
class is wrongly implemented by Microsoft, that will be a disaster!

.



Relevant Pages

  • Re: What makes a class view as an embed object
    ... In many string classes, such as ... there are converters to pointer to const char. ... value of the string class object. ... MyString mystring; ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Can Java Programmer Learn C++ Quickly?
    ... Every String class I've ever seen used a ... Mine added a reference count (and used a fancy, ... adding a single character doesn't always require reallocation -- since ...
    (comp.lang.java.programmer)
  • Re: Problem With C?
    ... int main(int argc, char **argv) { ... I have copied a full string into a char and prints that string ...
    (comp.lang.c)
  • Re: cast operator
    ... > I have a string class, which is a wrapper for a char * ... Then you pretty much give a const char* to anything expecting a String and it will ... It converts you String class to a const char*. ...
    (comp.lang.cpp)
  • Re: How can a string by accidently modified?
    ... modify a character string is an undefined behavior. ... int main ... > int main(int argc, char **argv){ ...
    (comp.lang.c)