(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.c-torture/
execute/
20000917-1.c
       1  /* This bug exists in gcc-2.95, egcs-1.1.2, gcc-2.7.2 and probably
       2     every other version as well.  */
       3  
       4  typedef struct int3 { int a, b, c; } int3;
       5  
       6  int3
       7  one (void)
       8  {
       9    return (int3) { 1, 1, 1 };
      10  }
      11  
      12  int3
      13  zero (void)
      14  {
      15    return (int3) { 0, 0, 0 };
      16  }
      17  
      18  int
      19  main (void)
      20  {
      21    int3 a;
      22  
      23    /* gcc allocates a temporary for the inner expression statement
      24       to store the return value of `one'.
      25  
      26       gcc frees the temporaries for the inner expression statement.
      27  
      28       gcc realloates the same temporary slot to store the return
      29       value of `zero'.
      30  
      31       gcc expands the call to zero ahead of the expansion of the
      32       statement expressions.  The temporary gets the value of `zero'.
      33  
      34       gcc expands statement expressions and the stale temporary is
      35       clobbered with the value of `one'.  The bad value is copied from
      36       the temporary into *&a.  */
      37  
      38    *({ ({ one (); &a; }); }) = zero ();
      39    if (a.a && a.b && a.c)
      40      abort ();
      41    exit (0);
      42  }