modernc.org/cc@v1.0.1/testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compat/struct-align.c (about)

     1  typedef union
     2  {
     3    struct {int a; int b;} s;
     4    double d;
     5  } T;
     6  
     7  int h (T *);
     8  T g (T);
     9  
    10  #if COMPILER != 1
    11  h (T *x)
    12  {
    13    if (x->s.a != 0 || x->s.b != 1)
    14      abort ();
    15  }
    16  #endif
    17  
    18  #if COMPILER != 2
    19  T
    20  g (T x)
    21  {
    22    if (x.s.a != 13 || x.s.b != 47)
    23      abort ();
    24    x.s.a = 0;
    25    x.s.b = 1;
    26    h (&x);
    27    return x;
    28  }
    29  #endif
    30  
    31  #if COMPILER != 1
    32  f ()
    33  {
    34    T x;
    35    x.s.a = 13;
    36    x.s.b = 47;
    37    g (x);
    38    if (x.s.a != 13 || x.s.b != 47)
    39      abort ();
    40    x = g (x);
    41    if (x.s.a != 0 || x.s.b != 1)
    42      abort ();
    43  }
    44  #endif
    45  
    46  #if COMPILER != 2
    47  main ()
    48  {
    49    f ();
    50    exit (0);
    51  }
    52  #endif