[LLVMbugs] [Bug 13003] New: implicit type conversion at construction time
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu May 31 23:04:44 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=13003
Bug #: 13003
Summary: implicit type conversion at construction time
Product: clang
Version: trunk
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: C++11
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: vallentin at icir.org
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
I am struggling with making C++11 code Clang compatible and ran into a case
where GCC >= 4.6 accepts code and Clang >= 3.1 doesn't. Clang deems a
`candidate constructor not viable`.
Here is a trimmed down example to illustrate the issue:
#include <utility>
template <typename...>
struct T;
template<>
struct T<>
{
typedef T super;
constexpr T() { }
template <typename... Args>
T(Args&&...) { }
};
template <typename Head, typename... Tail>
struct T<Head, Tail...> : T<Tail...>
{
typedef T<Tail...> super;
Head head;
T(Head arg) : super(), head(std::move(arg)) { }
};
struct void_type
{
constexpr void_type() { }
constexpr void_type(const void_type&) { }
void_type& operator=(const void_type&) = default;
template <typename Arg0, typename... Args>
void_type(Arg0&&, Args&&...) { }
};
struct atom { };
int main()
{
atom a;
T<void_type> t(a);
return 0;
}
The error I get is:
ctor-init.cpp:44:18: error: no matching constructor for initialization of
'T<void_type>'
T<void_type> t(a);
^ ~
ctor-init.cpp:19:8: note: candidate constructor (the implicit copy
constructor) not viable: no known conversion from 'atom' to 'const
T<void_type>' for 1st argument;
struct T<Head, Tail...> : T<Tail...>
^
ctor-init.cpp:25:5: note: candidate constructor not viable: no known
conversion from 'atom' to 'void_type' for 1st argument;
T(Head arg) : super(), head(std::move(arg)) { }
^
1 error generated.
I do not understand why clang complains about the lack of a conversion
possibility, because I think this "catch-all" constructor should work:
template <typename Arg0, typename... Args>
void_type(Arg0&&, Args&&...) { }
So the error I am confused about is:
ctor-init.cpp:25:5: note: candidate constructor not viable: no known
conversion from 'atom' to 'void_type' for 1st argument;
T(Head arg) : super(), head(std::move(arg)) { }
^
After all, GCC accepts the code.
(This ticket started at stackoverflow:
http://stackoverflow.com/q/10840769/1170277)
--
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