News for hackers. Stuff that matters.
Re:Const all the things? by cyber_kinetist on Monday January 24, 2022 @12:41PM (#30061045)
Oof, that’s a bit painful. I thought you could rely on NRVO for recent versions of gcc and clang, but feel I should be a lot more careful after seeing that example.
Re:Const all the things? by jcelerier on Tuesday January 25, 2022 @05:09PM (#30078818)
From what I could see through hundreds of godbolt snippets, if you declare the variable you'll return at the very top of the function before any control flow, NRVO will pretty much always happen.