Hello,
does anybody know why in the following code 's' contains trash upon creation, but becomes valid after creating another QString?


Qt Code:
  1. #include <QApplication>
  2. #include <QDebug>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. QApplication app(argc, argv);
  7.  
  8. const QString& s = QString("hello").append("world");
  9. qDebug() << s; // s is invalid here (seen in the debugger)
  10.  
  11. QString t = QString("hello").append("world");
  12. qDebug() << s; // s is ok (??????)
  13.  
  14. return 0;
  15. }
To copy to clipboard, switch view to plain text mode 
Qt 4.7
VS 2008 SP2
Vista