(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
analyzer/
pr98575-1.c
       1  /* A malloced pointer that's written to a global pointer shouldn't be
       2     reported as leaking, even if an unknown function has been called
       3     (PR analyzer/98575).  */
       4  
       5  void **g;
       6  
       7  extern void unknown_fn (void);
       8  
       9  /* Without a call to unknown_fn.  */
      10  
      11  int test_1 (void)
      12  {
      13    void *p;
      14    p = __builtin_malloc(1024);
      15    *g = p;
      16    return 0;
      17  }
      18  
      19  /* With a call to unknown_fn in various places.  */
      20  
      21  int test_2 (void)
      22  {
      23    void *p;
      24    unknown_fn ();
      25    p = __builtin_malloc(1024);
      26    *g = p;
      27    return 0;
      28  }
      29  
      30  int test_3 (void)
      31  {
      32    void *p;
      33    p = __builtin_malloc(1024);
      34    unknown_fn ();
      35    *g = p;
      36    return 0;
      37  }
      38  
      39  int test_4 (void)
      40  {
      41    void *p;
      42    p = __builtin_malloc(1024);
      43    *g = p;
      44    unknown_fn ();
      45    return 0;
      46  }