1  /* { dg-do compile } */
       2  /* { dg-options "-fdiagnostics-path-format=none" } */
       3  
       4  #include <stdlib.h>
       5  
       6  void *wrapped_malloc (size_t size)
       7  {
       8    return malloc (size);
       9  }
      10  
      11  void wrapped_free (void *ptr)
      12  {
      13    free (ptr); /* { dg-warning "double-free of 'ptr' \\\[CWE-415\\]" } */
      14  }
      15  
      16  typedef struct boxed_int
      17  {
      18    int i;
      19  } boxed_int;
      20  
      21  boxed_int *
      22  make_boxed_int (int i)
      23  {
      24    boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
      25    result->i = i;
      26    return result;
      27  }
      28  
      29  void
      30  free_boxed_int (boxed_int *bi)
      31  {
      32    wrapped_free (bi);
      33  }
      34  
      35  void test (int i)
      36  {
      37    boxed_int *obj = make_boxed_int (i);
      38  
      39    free_boxed_int (obj);
      40  
      41    free_boxed_int (obj);
      42  }
      43