| 1 |
/* PR tree-optimization/92879 - incorrect warning of __builtin_memset |
| 2 |
offset is out of the bounds on zero-size allocation and initialization |
| 3 |
{ dg-do compile } |
| 4 |
{ dg-options "-O2 -Wall -fdump-tree-optimized" } */ |
| 5 |
|
| 6 |
inline void* operator new (__SIZE_TYPE__, void * v) |
| 7 |
{ |
| 8 |
return v; |
| 9 |
} |
| 10 |
|
| 11 |
struct S |
| 12 |
{ |
| 13 |
int* p; |
| 14 |
int m; |
| 15 |
|
| 16 |
S (int i) |
| 17 |
{ |
| 18 |
m = i; |
| 19 |
p = (int*) new unsigned char [sizeof (int) * m]; |
| 20 |
|
| 21 |
for (int i = 0; i < m; i++) |
| 22 |
new (p + i) int (); |
| 23 |
} |
| 24 |
}; |
| 25 |
|
| 26 |
S a (0); |
| 27 |
|
| 28 |
/* Verify the loop has been eliminated. |
| 29 |
{ dg-final { scan-tree-dump-not "goto" "optimized" } } */ |