[llvm-bugs] [Bug 47713] New: Instantiation backtrace omits important element
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Oct 2 15:34:56 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=47713
Bug ID: 47713
Summary: Instantiation backtrace omits important element
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++17
Assignee: unassignedclangbugs at nondot.org
Reporter: bballo at mozilla.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
Given the following (invalid) code:
struct Noncopyable {
Noncopyable(const Noncopyable&) = delete;
};
template <class T>
struct Wrapper2 {
T storage;
Wrapper2(const T& val) : storage{val} {}
};
template <class T>
struct Wrapper {
Wrapper2<T> storage;
constexpr Wrapper(const T& val) : storage{val} {}
};
Wrapper<Noncopyable> foo(Noncopyable& a) { return Wrapper<Noncopyable>(a); }
compiling with clang (any recent version including trunk) with -std=c++17 gives
the following errors:
test.cpp:8:28: error: call to deleted constructor of 'Noncopyable'
Wrapper2(const T& val) : storage{val} {}
^ ~~~~~
test.cpp:14:37: note: in instantiation of member function
'Wrapper2<Noncopyable>::Wrapper2' requested here
constexpr Wrapper(const T& val) : storage{val} {}
^
test.cpp:2:3: note: 'Noncopyable' has been explicitly marked deleted here
Noncopyable(const Noncopyable&) = delete;
^
Observe that the backtrace omits a key element, the one that points to the
point of instantiation of Wrapper<Noncopyable> on the last line of the file.
If you image the wrapper classes being defined in utility headers, and the
point of instantiation being somewhere in a large translation unit, seeing this
error can leave you searching for a long time to find the point of
instantiation that you need to actually fix.
Making any of the following changes makes the desired backtrace element appear:
* Making the constructor of Wrapper not constexpr
* Making the constructor of Wrapper2 constexpr
* Using -std=c++14 rather than -std=c++17
--
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/20201002/64df46f1/attachment.html>
More information about the llvm-bugs
mailing list