(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.c-torture/
execute/
20071108-1.c
       1  /* PR tree-optimization/32575 */
       2  
       3  extern void abort (void);
       4  
       5  struct S
       6  {
       7    void *s1, *s2;
       8    unsigned char s3, s4, s5;
       9  };
      10  
      11  __attribute__ ((noinline))
      12  void *
      13  foo (void)
      14  {
      15    static struct S s;
      16    return &s;
      17  }
      18  
      19  __attribute__ ((noinline))
      20  void *
      21  bar ()
      22  {
      23    return (void *) 0;
      24  }
      25  
      26  __attribute__ ((noinline))
      27  struct S *
      28  test (void *a, void *b)
      29  {
      30    struct S *p, q;
      31    p = foo ();
      32    if (p == 0)
      33      {
      34        p = &q;
      35        __builtin_memset (p, 0, sizeof (*p));
      36      }
      37    p->s1 = a;
      38    p->s2 = b;
      39    if (p == &q)
      40      p = 0;
      41    return p;
      42  }
      43  
      44  int
      45  main (void)
      46  {
      47    int a;
      48    int b;
      49    struct S *z = test ((void *) &a, (void *) &b);
      50    if (z == 0 || z->s1 != (void *) &a || z->s2 != (void *) &b || z->s3 || z->s4)
      51      abort ();
      52    return 0;
      53  }