[Bug c++/89793] New: Implicit conversion to std::string is ambiguous on GCC 8.2 but not GCC 7.3

2019-03-21 Thread duyang.seu at gmail dot com
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
>::construct(std::allocator_traits >::allocator_type&, _Up*, _Args&& ...) [with _Up =
Message; _Args = {StringType}; _Tp = Message;
std::allocator_traits >::allocator_type
 = std::allocator]’
/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; __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; _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; _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; _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; _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::EnqueueImpl(T1&&, const
Queue::Type&) [with T1 = StringType; T2 = StringType; M = Message]’
message.cpp:63:5:   required from ‘void Queue::Enqueue(T&&) [with T =
StringType; M = Message]’
message.cpp:86:29:   required from here
message.cpp:47:60: error: call of overloaded ‘basic_string()’ is ambiguous
   Message(String&& data) : data_{std::forward(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,
 

[Bug c++/89793] Implicit conversion to std::string is ambiguous on GCC 8.2 but not GCC 7.3

2019-03-22 Thread duyang.seu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89793

--- Comment #2 from du yang  ---
Created attachment 46009
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46009&action=edit
GCC 7.3.1 source file dump

GCC version:
gcc version 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC) 

System Type:
CentOS Linux release 7.5.1804 (Core) 

GCC Configured options:
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-7/root/usr
--mandir=/opt/rh/devtoolset-7/root/usr/share/man
--infodir=/opt/rh/devtoolset-7/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 --enable-plugin --with-linker-hash-style=gnu
--enable-initfini-array --with-default-libstdcxx-abi=gcc4-compatible
--with-isl=/builddir/build/BUILD/gcc-7.3.1-20180303/obj-x86_64-redhat-linux/isl-install
--enable-libmpx --enable-gnu-indirect-function --with-tune=generic
--with-arch_32=i686 --build=x86_64-redhat-linux

Comments:
Please see attached for a GCC 7.3.1 source file dump and help confirm your
assumptions.

[Bug c++/89793] Implicit conversion to std::string is ambiguous on GCC 8.2 but not GCC 7.3

2019-03-23 Thread duyang.seu at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89793

--- Comment #8 from du yang  ---

> 
> struct Message {
>   template
> Message(T&& t) : s{t} { }
>   string s;
> };
> 

By the way, it works on both GCC 8 & 7, if change the code above as below
(change to use assignment),

 struct Message {
   template
 Message(T&& t) { s = t; }
   string s;
 };