-
-
Notifications
You must be signed in to change notification settings - Fork 262
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Consider the following code:
struct A {};
struct Test
{
Test(const A &);
Test(A &&);
};
std::optional<Test> foo()
{
A a;
return a;
}
in return statement constructor from rvalue reference is called (https://gcc.godbolt.org/z/KeWb4e). This is due to https://en.cppreference.com/w/cpp/language/return "Automatic move from local variables and parameters" part. This also could be seen in AST.
However, the output is (for the foo()):
std::optional<Test> foo()
{
A a = A();
return std::optional<Test>(a);
}
Here lvalue refeference constructor is called.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working