https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88971
--- Comment #5 from Marat Stanichenko <maratrus at mail dot ru> --- (In reply to Richard Biener from comment #1) > This is because it still needs to generate the std::string objects at the > caller Thank you very much for the comment! That is probably why I had to add another string parameter to the function `PrintBad` in the example provided to trigger this behaviour. The fact is that in the production environment where I managed to spot this, the compiler could not optimize the function that is very similar to `PrintGood` and has just a single string parameter. I didn't manage to reproduce it when simplifying things while preparing a test-case here. Do you believe that compiler can do better in such situations? Or the current behaviour is perfectly valid and no improvements are really needed?