https://bugs.llvm.org/show_bug.cgi?id=48732
Bug ID: 48732
Summary: Clang is too strict on object lifetime for automatic
storage duration
Product: clang
Version: trunk
Hardware: PC
OS: other
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
Behavior displayed in https://godbolt.org/z/n5Wenn
Reproducing code repeated here:
template <typename T>
constexpr void f(T& t) {
t.~T();
}
struct S {
constexpr ~S() { }
};
constexpr int g() {
{
// This should be fine, provided there are no more reads of
// 'i' before a new object lifetime is created.
int i = 0;
f(i);
}
{
// This should be UB: S::~S() is a non-trivial dtor.
S s{};
f(s);
}
return 0;
}
static_assert(g() == 0);
Relevant Standardese:
* http://eel.is/c++draft/basic.life#5
* http://eel.is/c++draft/basic.life#9
Currently, Clang errors on the first block of code using int i, though I
believe the first block of code should be fine as int does not have a
non-trivial destructor (http://eel.is/c++draft/basic.life#9). Note that the
second block should produce an error (which Clang does) as struct S does have a
non-trivial destructor.
--
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