summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fixuns-trunc-1.c
blob: 0d0942952497ab6ba2afbc65085ce70c1d71dc3e (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
/* { dg-do run } */
/* { dg-options "-std=c99" } */

unsigned long foo(double d)
{
  return (unsigned long) d;
}

extern void abort(void);

int main(void)
{
  double d;
  unsigned long l;

#ifdef __LP64__
  d = 9223372036854775808.7;
  l = 1LL << 63;

  if (foo(d) != l)
    abort();
#endif

  d = 122485.2;
  l = 122485;

  if (foo(d) != l)
    abort();

  return 0;
}