[llvm-bugs] [Bug 34744] New: Clang produces less useful error message when explicit constructor invoked implicitly
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Sep 27 05:12:51 PDT 2017
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: unassignedclangbugs at nondot.org
Reporter: csaba_22 at yahoo.co.uk
CC: dgregor at apple.com, llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170927/10ffa965/attachment-0001.html>
More information about the llvm-bugs
mailing list