1  typedef __SIZE_TYPE__ size_t;
       2  #define NULL ((void *)0)
       3  
       4  extern size_t
       5  strlen(const char* __s) __attribute__((__nothrow__, __leaf__))
       6  __attribute__((__pure__)) __attribute__((__nonnull__(1)));
       7  
       8  extern void*
       9  malloc(size_t __size) __attribute__((__nothrow__, __leaf__))
      10  __attribute__((__malloc__)) __attribute__((__alloc_size__(1)));
      11  
      12  extern int
      13  snprintf(char* __restrict __s, size_t size, const char* __restrict, ...)
      14    __attribute__((__nothrow__));
      15  
      16  char *
      17  test_1 (const char *a, const char *b)
      18  {
      19    size_t sz = strlen (a) + strlen (b) + 2;
      20    char *p = malloc (sz);
      21    if (!p)
      22      return NULL;
      23    snprintf (p, sz, "%s/%s", a, b);
      24    return p;
      25  }
      26  
      27  void
      28  test_2 (const char *a, const char *b)
      29  {
      30    size_t sz = strlen (a) + strlen (b) + 2;
      31    char *p = malloc (sz); /* { dg-message "allocated here" "PR 107017" { xfail *-*-* } } */
      32    if (!p)
      33      return;
      34    snprintf (p, sz, "%s/%s", a, b); /* { dg-warning "leak of 'p'" "PR 107017" { xfail *-*-* } } */
      35  }