[LLVMbugs] [Bug 12147] New: Unhelpful error message for trying to use an explicit constructor with uniform initialization
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Feb 29 20:08:43 PST 2012
http://llvm.org/bugs/show_bug.cgi?id=12147
Bug #: 12147
Summary: Unhelpful error message for trying to use an explicit
constructor with uniform initialization
Product: clang
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P
Component: C++0x
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: seth.cantrell at gmail.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
The code:
std::unique_ptr<int> j = {new int(0)};
Has a long error message complaining about a bunch of constructors that fail to
match.
error: no matching constructor for initialization of 'std::unique_ptr<int>'
std::unique_ptr<int> j = {new int(0)};
^ ~~~~~~~~~~~~
../libcxx/include/memory:2535:23: note: candidate constructor (the implicit
copy constructor) not viable: no
known conversion from 'int *' to 'const std::__1::unique_ptr<int,
std::__1::default_delete<int> > &' for
1st argument;
class _LIBCPP_VISIBLE unique_ptr
^
../libcxx/include/memory:2564:31: note: candidate constructor not viable: no
known conversion from 'int *' to
'nullptr_t' for 1st argument;
_LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t) _NOEXCEPT
^
../libcxx/include/memory:2591:31: note: candidate constructor not viable: no
known conversion from 'int *' to
'std::__1::unique_ptr<int, std::__1::default_delete<int> >' for 1st
argument;
_LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT
^
../libcxx/include/memory:2595:9: note: candidate template ignored: failed
template argument deduction
unique_ptr(unique_ptr<_Up, _Ep>&& __u,
^
../libcxx/include/memory:2610:35: note: candidate template ignored: failed
template argument deduction
_LIBCPP_INLINE_VISIBILITY unique_ptr(auto_ptr<_Up>&& __p,
^
../libcxx/include/memory:2558:31: note: candidate constructor not viable:
requires 0 arguments, but 1 was
provided
_LIBCPP_INLINE_VISIBILITY unique_ptr() _NOEXCEPT
^
../libcxx/include/memory:2578:31: note: candidate constructor not viable:
requires 2 arguments, but 1 was
provided
_LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename conditional<
^
../libcxx/include/memory:2585:31: note: candidate constructor not viable:
requires 2 arguments, but 1 was
provided
_LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename
remove_reference<deleter_type>::type&& __d)
^
1 error generated.
GCC 4.5 has the error message:
prog.cpp: In function 'int main()':
prog.cpp:4:41: error: converting to 'std::unique_ptr<int>' from initializer
list would use explicit constructor 'std::unique_ptr<_Tp,
_Tp_Deleter>::unique_ptr(_Tp*) [with _Tp = int, _Tp_Deleter =
std::default_delete<int>, _Tp* = int*]'
http://ideone.com/h8rgq
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list