https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86573
Bug ID: 86573 Summary: Failure to optimise passing simple values to inlined function Product: gcc Version: tree-ssa Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: s_gccbugzilla at nedprod dot com Target Milestone: --- #include <string> inline size_t calc(std::string a, std::string b) { return a.size() + b.size(); } int main() { std::string a = "Hello world", b = "Goodbye world"; return calc(std::move(a), std::move(b)); } This should generate: main: # @main mov eax, 24 ret Like clang does. See https://godbolt.org/g/EAggKH. But it instead generates this spew with gcc trunk: https://godbolt.org/g/3LmfTc Also it should generate the above return of 24 if passing by value. clang currently fails that, I have reported a bug to them about it.