very strange output with const ref initialise-Collection of common programming errors

In one of my project, i initialized a const std::string& with a const char (know at compile time), and the result of print it was … surprising.

I use gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) on Ubuntu 12.04×32

Exemple:

#include 
#include 
using namespace std;

class A
{
    public:
        A() : str("test"){};
    const string& str;
};

int main(int argc,char* argv[])
{ 
  A a;
  cout

Originally posted 2013-11-09 22:57:36.