[llvm-bugs] [Bug 41819] New: Bad diagnostic when trying to copy an uncopyable type
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu May 9 08:43:57 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=41819
Bug ID: 41819
Summary: Bad diagnostic when trying to copy an uncopyable type
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: barry.revzin at gmail.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
Same issue as gcc's bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90413):
template<class T>
struct Bar {
Bar() {}
Bar(const Bar&) {
static_assert(sizeof(T) == 1, "");
}
};
template<class T>
struct Foo {
Foo() {}
#ifdef DEFAULT
Foo(const Foo&) = default;
#else
Foo(const Foo& o) : b(o.b) {}
#endif
Bar<T> b;
};
int main() {
Foo<int> f;
Foo<int> g = f;
}
Without -DDEFAULT, the error points to the offending line (you can see the
construction of 'g' in the error trace):
source>:5:9: error: static_assert failed due to requirement 'sizeof(int) == 1'
""
static_assert(sizeof(T) == 1, "");
^ ~~~~~~~~~~~~~~
<source>:14:25: note: in instantiation of member function 'Bar<int>::Bar'
requested here
Foo(const Foo& o) : b(o.b) {}
^
<source>:21:18: note: in instantiation of member function 'Foo<int>::Foo'
requested here
Foo<int> g = f;
^
1 error generated.
Compiler returned: 1
With -DDEFAULT, the error does not point to the offending line at all:
source>:5:9: error: static_assert failed due to requirement 'sizeof(int) == 1'
""
static_assert(sizeof(T) == 1, "");
^ ~~~~~~~~~~~~~~
<source>:12:5: note: in instantiation of member function 'Bar<int>::Bar'
requested here
Foo(const Foo&) = default;
^
1 error generated.
Compiler returned: 1
In larger examples, this makes it very hard to determine the actual source of
problem -- since it doesn't even appear.
--
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/20190509/0896d3cc/attachment.html>
More information about the llvm-bugs
mailing list