Thank you for your efforts Wysota.

It turns out the code does not work "because the standard says so". In other words, while this code is ok:

Qt Code:
  1. // bind a temporary *expression* to a const reference
  2. const QString& s = QString("hello");
To copy to clipboard, switch view to plain text mode 

this one leaves a dangling reference:

Qt Code:
  1. // bind a temporary *object* to a const reference
  2. const QString& s = QString("hello").append("");
To copy to clipboard, switch view to plain text mode 

I believe that from a purely "technical" point of view there is nothing wrong with the second snippet (a compiler could easily generate working code), but in fact it is not supposed to work.