http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58594
Bug ID: 58594 Summary: std::make_shared does not accept const types as parameters Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: akim.demaille at gmail dot com The following piece of code works with 4.8, clang 3.3 and 3.4, but not 4.9. I expect the code to be right, and 4.9 to be wrong, but even if it were the converse, the location is useless: it's the end of the translation unit, not the location of the error. It works if I remove the const. Cheers! $ cat foo.cc #include <memory> int main() { const int f = 42; auto fp = std::make_shared<const int>(f); return 51; } $ g++-mp-4.8 --version g++-mp-4.8 (MacPorts gcc48 4.8.1_3) 4.8.1 Copyright (C) 2013 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++-mp-4.8 -Wall -std=c++11 foo.cc $ g++-mp-4.9 --version g++-mp-4.9 (MacPorts gcc49 4.9-20130915_0) 4.9.0 20130915 (experimental) Copyright (C) 2013 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++-mp-4.9 -Wall -std=c++11 foo.cc In file included from /opt/local/include/gcc49/c++/bits/shared_ptr.h:52:0, from /opt/local/include/gcc49/c++/memory:82, from foo.cc:1: /opt/local/include/gcc49/c++/bits/shared_ptr_base.h: In instantiation of 'void* std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_M_get_deleter(const std::type_info&) [with _Tp = const int; _Alloc = std::allocator<int>; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]': foo.cc:9:1: required from here /opt/local/include/gcc49/c++/bits/shared_ptr_base.h:462:58: error: invalid conversion from 'const void*' to 'void*' [-fpermissive] return __ti == typeid(_Sp_make_shared_tag) ? _M_ptr() : nullptr; ^ Cheers!