[llvm-bugs] [Bug 47805] New: constexpr evaluator incorrectly claims double delete with function parameter
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Oct 12 10:24:54 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=47805
Bug ID: 47805
Summary: constexpr evaluator incorrectly claims double delete
with function parameter
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: david at doublewise.net
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
The following translation unit
```
struct S {
int * m_ptr;
constexpr S():
m_ptr(new int())
{
}
constexpr S(S && other) noexcept:
m_ptr(other.m_ptr)
{
other.m_ptr = nullptr;
}
constexpr ~S() noexcept {
delete m_ptr;
}
};
constexpr bool test(S v) {
auto x = static_cast<S &&>(v);
return true;
}
static_assert(test(S()));
```
is rejected with
```
<source>:23:15: error: static_assert expression is not an integral constant
expression
static_assert(test(S()));
^~~~~~~~~
<source>:14:3: note: delete of pointer that has already been deleted
delete m_ptr;
^
<source>:23:20: note: in call to '&S()->~S()'
static_assert(test(S()));
^
1 error generated.
Compiler returned: 1
```
This problem does not occur if `v` is turned into a local variable instead of a
function parameter.
See it live: https://godbolt.org/z/hcv88h
--
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/20201012/c7598a18/attachment.html>
More information about the llvm-bugs
mailing list