https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89793
Bug ID: 89793 Summary: Implicit conversion to std::string is ambiguous on GCC 8.2 but not GCC 7.3 Product: gcc Version: 8.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: duyang.seu at gmail dot com Target Milestone: --- Created attachment 46006 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46006&action=edit the preprocessed file GCC Version: gcc version 8.2.1 20180905 (Red Hat 8.2.1-3) (GCC) System Type: CentOS Linux release 7.5.1804 (Core) GCC Configured options: COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-8/root/usr --mandir=/opt/rh/devtoolset-8/root/usr/share/man --infodir=/opt/rh/devtoolset-8/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-8.2.1-20180905/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix Compilation errors: message.cpp: In instantiation of ‘Message::Message(String&&) [with String = StringType]’: /opt/rh/devtoolset-8/root/usr/include/c++/8/ext/new_allocator.h:136:4: required from ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = Message; _Args = {StringType}; _Tp = Message]’ /opt/rh/devtoolset-8/root/usr/include/c++/8/bits/alloc_traits.h:475:4: required from ‘static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<s td::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = Message; _Args = {StringType}; _Tp = Message; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<Message>]’ /opt/rh/devtoolset-8/root/usr/include/c++/8/bits/shared_ptr_base.h:543:39: required from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& . ..) [with _Args = {StringType}; _Tp = Message; _Alloc = std::allocator<Message>; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2]’ /opt/rh/devtoolset-8/root/usr/include/c++/8/bits/shared_ptr_base.h:656:4: required from ‘std::__shared_count<_Lp>::__shared_count(std::_Sp_make_shared_tag, _Tp*, const _Alloc&, _A rgs&& ...) [with _Tp = Message; _Alloc = std::allocator<Message>; _Args = {StringType}; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2]’ /opt/rh/devtoolset-8/root/usr/include/c++/8/bits/shared_ptr_base.h:1322:35: required from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args && ...) [with _Alloc = std::allocator<Message>; _Args = {StringType}; _Tp = Message; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2]’ /opt/rh/devtoolset-8/root/usr/include/c++/8/bits/shared_ptr.h:360:64: required from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _ Alloc = std::allocator<Message>; _Args = {StringType}; _Tp = Message]’ /opt/rh/devtoolset-8/root/usr/include/c++/8/bits/shared_ptr.h:706:14: required from ‘std::shared_ptr<_Tp> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = Message; _Al loc = std::allocator<Message>; _Args = {StringType}]’ /opt/rh/devtoolset-8/root/usr/include/c++/8/bits/shared_ptr.h:722:39: required from ‘std::shared_ptr<_Tp> std::make_shared(_Args&& ...) [with _Tp = Message; _Args = {StringType}]’ message.cpp:77:44: required from ‘void Queue<M>::EnqueueImpl(T1&&, const Queue<M>::Type<T2>&) [with T1 = StringType; T2 = StringType; M = Message]’ message.cpp:63:5: required from ‘void Queue<M>::Enqueue(T&&) [with T = StringType; M = Message]’ message.cpp:86:29: required from here message.cpp:47:60: error: call of overloaded ‘basic_string(<brace-enclosed initializer list>)’ is ambiguous Message(String&& data) : data_{std::forward<String>(data)} {} ^ In file included from /opt/rh/devtoolset-8/root/usr/include/c++/8/string:52, from /usr/local/include/boost/utility/string_view_fwd.hpp:21, from /usr/local/include/boost/utility/string_view.hpp:22, from /usr/local/include/boost/beast/core/string.hpp:19, from /usr/local/include/boost/beast/core/file_base.hpp:14, from /usr/local/include/boost/beast/core/type_traits.hpp:14, from /usr/local/include/boost/beast/http/basic_dynamic_body.hpp:14, from /usr/local/include/boost/beast/http.hpp:15, from message.cpp:1: /opt/rh/devtoolset-8/root/usr/include/c++/8/bits/basic_string.h:3562:7: note: candidate: ‘std::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ basic_string(basic_string&& __str) ^~~~~~~~~~~~ In file included from /opt/rh/devtoolset-8/root/usr/include/c++/8/string:53, from /usr/local/include/boost/utility/string_view_fwd.hpp:21, from /usr/local/include/boost/utility/string_view.hpp:22, from /usr/local/include/boost/beast/core/string.hpp:19, from /usr/local/include/boost/beast/core/file_base.hpp:14, from /usr/local/include/boost/beast/core/type_traits.hpp:14, from /usr/local/include/boost/beast/http/basic_dynamic_body.hpp:14, from /usr/local/include/boost/beast/http.hpp:15, from message.cpp:1: /opt/rh/devtoolset-8/root/usr/include/c++/8/bits/basic_string.tcc:609:5: note: candidate: ‘std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _ Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ basic_string<_CharT, _Traits, _Alloc>:: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /opt/rh/devtoolset-8/root/usr/include/c++/8/string:52, from /usr/local/include/boost/utility/string_view_fwd.hpp:21, from /usr/local/include/boost/utility/string_view.hpp:22, from /usr/local/include/boost/beast/core/string.hpp:19, from /usr/local/include/boost/beast/core/file_base.hpp:14, from /usr/local/include/boost/beast/core/type_traits.hpp:14, from /usr/local/include/boost/beast/http/basic_dynamic_body.hpp:14, from /usr/local/include/boost/beast/http.hpp:15, from message.cpp:1: /opt/rh/devtoolset-8/root/usr/include/c++/8/bits/basic_string.h:3491:7: note: candidate: ‘std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _Alloc&) [with _CharT = char ; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ basic_string(const _Alloc& __a); ^~~~~~~~~~~~ Command to reproduce the compilation errors: g++ -O2 -Wall -std=c++17 message.cpp -o test_message Comments: No such error on GCC7.3.1. The version is, gcc version 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC).