aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/analyzer/malloc-dce.c
blob: 7f5ec67877f490269f0204d392f6a5d9b1abd585 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
/* { dg-additional-options "-O2" } */
/* { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } */

#include <stdlib.h>

void test(void)
{
    void *ptr = malloc(512);
    free(ptr);
    free(ptr); /* { dg-warning "double-'free'" "" { xfail *-*-* } } */
}
/* With optimization, the whole of test() goes away in the "cddce" pass
   before the analysis pass sees it, and hence we get no error message.  */