https://bugs.llvm.org/show_bug.cgi?id=34744
Bug ID: 34744
Summary: Clang produces less useful error message when explicit
constructor invoked implicitly
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangb...@nondot.org
Reporter: csaba...@yahoo.co.uk
CC: dgre...@apple.com, llvm-bugs@lists.llvm.org
$ clang -v
clang version 5.0.0 (trunk 308427)
$ cat errmsg.cpp
#include <string>
#include <map>
namespace a {
struct AV {
explicit AV(std::string const&);
};
// ---
struct EAV;
typedef std::map<std::string, EAV> EAM;
struct EAV {
explicit EAV(AV const&);
};
// ---
struct UIRQ {
typedef EAM ET;
ET const& expected() const;
UIRQ & expected(ET const&);
};
}
int main()
{
a::UIRQ req;
req.expected({ {"kye", a::AV{ "valu" } } });
}
/* GCC 8
errmsg.cpp: In function ‘int main()’:
errmsg.cpp:32:47: error: converting to ‘std::pair<const
std::basic_string<char>, a::EAV>’ from initializer list would use explicit
constructor ‘constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U1 =
const char (&)[4]; _U2 = a::AV; typename std::enable_if<(std::_PCC<true, _T1,
_T2>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<true, _T1,
_T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> =
0; _T1 = const std::basic_string<char>; _T2 = a::EAV]’
req.expected({ {"kye", a::AV{ "valu" } } });
^
*/
/* clang 5.0.0
errmsg.cpp:32:9: error: no matching member function for call to 'expected'
req.expected({ {"kye", a::AV{ "valu" } } });
~~~~^~~~~~~~
errmsg.cpp:25:16: note: candidate function not viable: cannot convert
initializer list argument to 'const a::UIRQ::ET' (aka 'const
map<basic_string<char>, a::EAV>')
UIRQ & expected(ET const&);
^
errmsg.cpp:23:19: note: candidate function not viable: requires 0 arguments,
but 1 was provided
ET const& expected() const;
^
*/
The GCC error message mentions a hint to the problem (EAV constructor is
explicit). Clang's error message makes no mention of 'explicit'.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs