(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
analyzer/
write-to-const-1.c
       1  /* PR middle-end/90404 */
       2  
       3  const int c1 = 20; /* { dg-message "declared here" } */
       4  int test_1 (void)
       5  {
       6    *((int*) &c1) = 10; /* { dg-warning "write to 'const' object 'c1'" } */
       7    return c1;
       8  }
       9  
      10  /* Example of writing to a subregion (an element within a const array).  */
      11  
      12  const int c2[10]; /* { dg-message "declared here" } */
      13  int test_2 (void)
      14  {
      15    ((int*) &c2)[5] = 10; /* { dg-warning "write to 'const' object 'c2'" } */
      16    return c2[5];
      17  }
      18  
      19  const char s3[] = "012.45"; /* { dg-message "declared here" } */
      20  int test_3 (void)
      21  {
      22    char *p = __builtin_strchr (s3, '.');
      23    *p = 0; /* { dg-warning "write to 'const' object 's3'" } */
      24  
      25    if (__builtin_strlen (p) != 3)
      26      __builtin_abort ();
      27  
      28    return s3[3] == 0;
      29  }