[Bug c++/67302] New: copy elision in return (expression)
osensei80 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Aug 21 07:06:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67302
Bug ID: 67302
Summary: copy elision in return (expression)
Product: gcc
Version: 5.1.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: osensei80 at gmail dot com
Target Milestone: ---
Consider:
struct A
{
A() { std::cout << "default ctor\n"; }
A(const A&) { std::cout << "copy ctor\n"; }
A(A&&) { std::cout << "move ctor\n"; }
};
A bar()
{
A a;
return( a );
}
int main()
{
bar();
}
Compiling with option -std=c++11 the output is "default ctor". But compiling
with -std=c++14 or -std=c++1z the output is
default ctor
move ctor
Why get's the move not elided?
More information about the Gcc-bugs
mailing list