PR c/64856
[official-gcc.git] / gcc / testsuite / gcc.dg / fwrapv-1.c
bloba172b3b8fd7aea760ad9124332fb18ec8fb3e7aa
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 int
21 main()
23 int x = INT_MAX;
25 if (test(x) == x)
26 abort ();
27 return 0;