https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84012
Bug ID: 84012 Summary: [8 regression] error: cannot convert ‘const std::shared_ptr<std::a>’ to ‘std::a*’ in return Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: skpgkp1 at gmail dot com Target Milestone: --- This issue appear during freeorion compilation. Test case compile fine with GCC 7 and Clang 5 but fail with GCC 8. $ cat StyleFactory.cpp namespace std { template <typename> class shared_ptr {}; class a; template <class> class b { a *g() const; shared_ptr<a> e; }; template <class f> a *b<f>::g() const { return e; } } $ g++ --version g++ (GCC) 8.0.1 20180123 (experimental) Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ g++ -O2 -fPIC -std=c++11 -o StyleFactory.cpp.i.o -c StyleFactory.cpp StyleFactory.cpp: In member function ‘std::a* std::b< <template-parameter-1-1> >::g() const’: StyleFactory.cpp:8:48: error: cannot convert ‘const std::shared_ptr<std::a>’ to ‘std::a*’ in return template <class f> a *b<f>::g() const { return e; } ^ GCC 7 works fine. $ g++ --version g++ (GCC) 7.2.1 20180123 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ g++ -O2 -fPIC -std=c++11 -o StyleFactory.cpp.i.o -c StyleFactory.cpp $ echo $? 0 Clang 5 also work fine. $ clang++ --version clang version 5.0.1 Target: x86_64-unknown-linux-gnu Thread model: posix $ clang++ -O2 -fPIC -std=c++11 -o StyleFactory.cpp.i.o -c StyleFactory.cpp $ echo $? 0