Debian Codegraph @

gcc/testsuite/g++.dg/analyzer/pr100244.C

raw
1 // { dg-additional-options "-O1 -Wno-free-nonheap-object -Wno-analyzer-out-of-bounds" }
2 /* Disabled out-of-bounds checker because the output relied
3 on optimizations. out-of-bounds-placement-new.C tests
4 the same pattern but without optimizations. */
5
6 inline void *operator new (__SIZE_TYPE__, void *__p) { return __p; }
7
8 struct __aligned_buffer {
9 int _M_storage;
10 int *_M_addr() { return &_M_storage; }
11 };
12
13 struct _Hashtable_alloc {
14 int _M_single_bucket;
15 int *_M_buckets;
16 _Hashtable_alloc () { _M_buckets = &_M_single_bucket; }
17 ~_Hashtable_alloc () { delete _M_buckets; } // { dg-warning "on the stack" }
18 };
19
20 void
21 test01 (__aligned_buffer buf)
22 {
23 _Hashtable_alloc *tmp = new (buf._M_addr ()) _Hashtable_alloc;
24 tmp->~_Hashtable_alloc ();
25 }