Different compiler behavior for expression: auto p {make_pointer()};
问题 Which is the correct behaviour for the following program? // example.cpp #include <iostream> #include <memory> struct Foo { void Bar() const { std::cout << "Foo::Bar()" << std::endl; } }; std::shared_ptr<Foo> MakeFoo() { return std::make_shared<Foo>(); } int main() { auto p { MakeFoo() }; p->Bar(); } When I compile it in my Linux RHEL 6.6 workstation, I obtain the following results: $ g++ -v gcc version 5.1.0 (GCC) $ g++ example.cpp -std=c++14 -Wall -Wextra -pedantic $ ./a.out Foo::Bar() but