blob: d298d1a124c8b062ac2bddf9bb0fb2ced3fe1cd0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// PR c++/91859
// { dg-do run { target c++20 } }
// { dg-additional-options -O2 }
// { dg-skip-if "requires hosted libstdc++ for cstdlib malloc" { ! hostedlib } }
#include <cstdlib>
#include <new>
struct Expression {
int i = 0;
void *operator new(std::size_t);
void operator delete(Expression *, std::destroying_delete_t);
};
void * Expression::operator new(std::size_t sz)
{
return std::malloc(sz);
}
int i;
void Expression::operator delete(Expression *p, std::destroying_delete_t) // { dg-message "destroying delete" }
{
Expression * e = p;
::i = e->i;
p->~Expression();
std::free(p);
}
int main()
{
auto p = new Expression(); // { dg-warning "no corresponding dealloc" }
p->i = 1;
delete p;
if (i != 1)
__builtin_abort();
}
|