[Bug c++/95977] New: No deallocation of temporary in return-statement during constant evaluation
johelegp at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Jun 29 17:26:49 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95977
Bug ID: 95977
Summary: No deallocation of temporary in return-statement
during constant evaluation
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: johelegp at gmail dot com
Target Milestone: ---
See https://godbolt.org/z/iyRFxf.
```C++
struct X {
int* x{new int{42}};
X() = default;
constexpr X(const X& x) : x{new int{*x.x}} { }
constexpr ~X() { delete x; }
};
constexpr int f() { X x; return *X{x}.x; }
constexpr int z{f()};
```
```
<source>:4:45: error: 'f()' is not a constant expression because allocated
storage has not been deallocated
4 | constexpr X(const X& x) : x{new int{*x.x}} { }
| ^
```
More information about the Gcc-bugs
mailing list