summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/opt/cse2.C
blob: 325169dff348eb25f5994543b3ab50f171caddc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// This testcase caused ICE on IA-32 in simplify_unary_operation
// CSE did not assume SUBREGs changing mode from integral to floating.
// { dg-do run { target i?86-*-* sparc*-*-* x86_64-*-* } }
// { dg-options "-O2" }

struct A
{
  union
    {
      float f;
      unsigned int w;
    } a;

  static inline const A foo (void)
    {
      return A ((unsigned int) (__extension__ ((union { unsigned l; float d; })
					       { l: 0x3f800000 }).d));
    }
  inline A (float f) { a.f = f; }
  A ();
  inline A (unsigned int w) { a.w = w; }
};

A::A()
{
  *this = foo ();
}

A a;

extern "C" void abort (void);
extern "C" void exit (int);

int main ()
{
  if (a.a.w != 1)
    abort ();
  exit (0);
}