modernc.org/ccgo/v3@v3.16.14/lib/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/execute/pr15262.c (about)

     1  /* We used to mis-compile this testcase as we did not know that
     2     &a+offsetof(b,a) was the same as &a.b */
     3  struct A
     4  {
     5    int t;
     6    int i;
     7  };
     8  
     9  void
    10  bar (float *p)
    11  {
    12    *p = 5.2;
    13  }
    14  
    15  int
    16  foo(struct A *locp, int i, int str)
    17  {
    18    float f, g, *p;
    19    int T355;
    20    int *T356;
    21    /* Currently, the alias analyzer has limited support for handling
    22       aliases of structure fields when no other variables are aliased.
    23       Introduce additional aliases to confuse it.  */
    24    p =  i ? &g : &f;
    25    bar (p);
    26    if (*p > 0.0)
    27      str = 1;
    28  
    29    T355 = locp->i;
    30    T356 = &locp->i;
    31    *T356 = str;
    32    T355 = locp->i;
    33  
    34    return T355;
    35  }
    36  
    37  main ()
    38  {
    39    struct A loc;
    40    int str;
    41  
    42    loc.i = 2;
    43    str = foo (&loc, 10, 3);
    44    if (str!=1)
    45      abort ();
    46    return 0;
    47  }
    48