https://bugs.llvm.org/show_bug.cgi?id=51695
Bug ID: 51695
Summary: Clang not emitting destructor call when assignment
constructed with list
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++17
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
In the following code: https://godbolt.org/z/TK7ersK1M
#include <string>
#include <utility>
void doSomething();
class FooClass {
public:
FooClass() noexcept : ptr_() {}
FooClass(FooClass&& other) noexcept
: ptr_(std::exchange(other.ptr_, {})) {}
~FooClass() {
doSomething();
}
FooClass& operator=(FooClass other) noexcept {
std::swap(ptr_, other.ptr_);
return *this;
}
private:
void *ptr_;
};
template <typename T>
class WrapperClass {
public:
void run() noexcept {
wrapper_ = {};
}
private:
FooClass wrapper_;
};
void foo(WrapperClass<std::string> &A) {
A.run();
}
When compiled with either GCC (any std version) or Clang with C++14, the line
"wrapper_ = {};" in WrapperClass::run() will always generate a destructor call
in the end, which is expected.
However when compiled with Clang C++17, the destructor call is not generated,
which seems wrong to me.
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs