[Bug c++/86590] New: Codegen regression when passing std::string by value in C++ 17 and C++ 20
s_gccbugzilla at nedprod dot com
gcc-bugzilla@gcc.gnu.org
Thu Jul 19 17:49:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86590
Bug ID: 86590
Summary: Codegen regression when passing std::string by value
in C++ 17 and C++ 20
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: ---
If compiled as C++ 14:
#include <string>
inline size_t calc(std::string a, std::string b)
{
return a.size() + b.size();
}
int foo()
{
std::string a = "Hello world", b = "Goodbye world";
return calc(a, b);
}
...one gets:
foo():
mov eax, 24
ret
But if compiled as C++ 17 or later, one gets lots of spew:
https://godbolt.org/g/jCzpAS
Using std::move() generates the right result in C++ 17 or later:
https://godbolt.org/g/tHXpyy. I think it should also work by value, like it did
in C++ 11 and C++ 14.
More information about the Gcc-bugs
mailing list