1  extern void* malloc (__SIZE_TYPE__);
       2  
       3  const char* write_strchr_literal (int x)
       4  {
       5    char *p = __builtin_strchr ("123", x); 
       6    *p = 0; /* { dg-warning "dereference of NULL 'p'" "null deref" } */
       7    /* { dg-warning "write to string literal" "string literal" { target *-*-* } .-1 } */  
       8    return p;
       9  }
      10  
      11  const char* write_strchr_const_array (int x)
      12  {
      13    static const char a[] = "123";
      14    char *p = __builtin_strchr (a, x);
      15    *p = 0; /* { dg-warning "dereference of NULL 'p'" "null deref" } */
      16    /* { dg-warning "write to 'const' object 'a'" "write to const" { target *-*-* } .-1 } */  
      17    return a;
      18  }
      19  
      20  char* write_function (void)
      21  {
      22    char *p = (char*)malloc /* forgot arguments */;
      23    p[1] = 'a'; /* { dg-warning "write to function 'malloc'" } */
      24    __builtin_strcpy (p, "123");  /* { dg-warning "write to function 'malloc'" } */
      25    return p;
      26  }
      27  
      28  char* write_label (void)
      29  {
      30    char *p = (char*)&&L;
      31    *p = 0; /* { dg-warning "write to label 'L'" } */
      32  L:
      33    return p;
      34  }
      35  
      36  struct A { const int i; };
      37  
      38  extern /* not const */ struct A a;
      39  
      40  void write_const_member (void)
      41  {
      42    char *p = (char*)&a.i;
      43    *p = 0;   // missing warning
      44  }