-
-
Notifications
You must be signed in to change notification settings - Fork 262
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
The following example
#include <iostream>
#include <memory>
std::shared_ptr<int> create() {
return std::make_shared<int>(42);
}
int main()
{
const auto& car = create(); // 'const' disappeared!
//However, the following does not compile:
//std::shared_ptr<int> & ar = create();
//error: non-const lvalue reference to type 'shared_ptr<...>' cannot bind to a temporary of type 'shared_ptr<...>'
//must be:
const std::shared_ptr<int> & car2 = create();
}is translated incorrectly:
#include <iostream>
#include <memory>
std::shared_ptr<int> create() {
return std::make_shared<int>(42);
}
int main()
{
std::shared_ptr<int> & car = create(); // 'const' disappeared!
//However, the following does not compile:
//std::shared_ptr<int> & ar = create();
//error: non-const lvalue reference to type 'shared_ptr<...>' cannot bind to a temporary of type 'shared_ptr<...>'
//must be:
const std::shared_ptr<int> & car2 = create();
}Similar happens with const auto&&.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working