Merge from mainline.
[official-gcc.git] / gcc / testsuite / gcc.dg / fwrapv-1.c
blobf7ddda4a3b6c195a3df017cf822bb1b7d5f1f46b
1 /* Copyright (C) 2003 Free Software Foundation.
3 Test that the -fwrapv command line option is accepted and disables
4 "unsafe" optimizations that rely on undefined arithmetic overflow.
6 Written by Roger Sayle, 24th March 2003. */
8 /* { dg-do run } */
9 /* { dg-options "-O2 -fwrapv" } */
11 #include <limits.h>
13 extern void abort ();
15 int test(int x)
17 return (2*x)/2;
20 main()
22 int x = INT_MAX;
24 if (test(x) == x)
25 abort ();
26 return 0;