I actually found that gcc produced better code when string literals were static const and not constexpr.
Thanks for everyone who's commented here or on the bug tracker. What's clear is that pre-gcc-7 there is a very noticeable slowdown for functions where a temporary with a constexpr constructor relies on the named-return-value-optimisation. Even with gcc-7 there are non-trivial changes to the assembly produced, where I would have expected them to be identical (given that the temporary is constructed in a non-constexpr context). Still, at least the performance is the same. In any case, it's clear that these new features can have strange unintended consequences. Best, John. --- This email has been checked for viruses by AVG. http://www.avg.com