1 /* { dg-additional-options "-Wno-analyzer-too-complex" } */
2 /* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */
6 struct foo
{ int dummy
; };
13 if ((arr
= (struct foo
**)malloc(n
* sizeof(struct foo
*))) == NULL
)
16 for (i
= 0; i
< n
; i
++) {
17 if ((arr
[i
] = (struct foo
*)malloc(sizeof(struct foo
))) == NULL
) {
18 for (; i
>= 0; i
++) { /* { dg-warning "infinite loop" } */
19 /* This loop is in the wrong direction, so not technically an
20 infinite loop ("i" will eventually wrap around), but the
21 analyzer's condition handling treats the overflow as such.
22 In any case, the code is suspect and warrants a warning. */
23 free(arr
[i
]); /* { dg-bogus "double-'free'" } */
25 free(arr
); /* { dg-warning "leak" } */