1 // PR optimization/12926
2 // This failed on SPARC64 because the assignments to the bit-fields
3 // were wrongly swapped in the constructor.
4 
5 // { dg-do run }
6 // { dg-options "-O2" }
7 
8 extern "C" void abort(void);
9 
10 typedef __SIZE_TYPE__ size_t;
11 
12 void *my_out;
13 
14 struct A
15 {
16   enum Type {P, U, S};
17 
18   int foo1(void *, const char *);
19   int foo2(int, const Type);
20 
AA21   A (const size_t size, const Type type): mSize(size), mType(type)
22   {
23       foo2(foo1(my_out, "type = "), type);
24       foo2(foo1(my_out, "mType = "), mType);
25   }
26 
27   const size_t mSize : 8*sizeof(size_t) - 3;
28   Type mType : 2;
29 };
30 
31 int i;
32 
foo1(void * ios,const char * str)33 int A::foo1(void *ios, const char *str) { return 0; }
foo2(int v,const Type t)34 int A::foo2(int v, const Type t) { i=0; return 0; }
35 
main()36 int main()
37 {
38   A testa(2, A::S);
39 
40   if (testa.mType != A::S)
41      abort();
42 
43   return 0;
44 }
45