[LLVMbugs] [Bug 12692] New: Confusing error message when using illegal explicitly-defaulted function
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Apr 28 19:55:47 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=12692
Bug #: 12692
Summary: Confusing error message when using illegal
explicitly-defaulted function
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: martin.desharnais at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
#include <utility>
struct A
{
A(int& i) : m_i(i) { }
A(const A&) = delete;
A(A&&) = default; // Illegal (C++11 12.1.5): non-static data member with no
brace-or-equal-initializer is of reference type
A& operator=(const A&) = delete;
A& operator=(A&&) = default;
int& m_i;
};
int main()
{
int i = 10;
A a1(i);
A a2(i);
a1 = std::move(a2);
}
In the above code, it we can not ask the compiler to generate a default
move-constructor since we have a non-static reference type. But the error
message is criptic.
main.cpp:22:5: error: overload resolution selected implicitly-deleted move
assignment operator
a1 = std::move(a2);
^
main.cpp:11:5: note: candidate function has been explicitly deleted
A& operator=(A&&) = default;
^
main.cpp:10:5: note: candidate function has been explicitly deleted
A& operator=(const A&) = delete;
^
1 error generated.
I see two problems with this output:
1. The error message point out that the constructor have been
implicitly-deleted. But we can wonder why since we explicitly asked the
compiler to generate a default implementation.
2. The note message said that the constructor have been explicitly deleted and
show us a call to an explicitly defaulted constructor.
I think the error message should explained that the compiler was unable to
generate the default implementation because of the reference type present in
the class.
--
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