2017-09-26 Thomas Koenig <tkoenig@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gcc.dg / fwrapv-2.c
blobe260e545b52bb4a28ddac7c3b864e45066b65a51
1 /* Copyright (C) 2003 Free Software Foundation.
3 Test that the -fno-wrapv command line option is accepted and enables
4 "unsafe" optimizations that rely on undefined arithmetic overflow.
6 Written by Roger Sayle, 31st May 2003. */
8 /* { dg-do run } */
9 /* { dg-options "-O2 -fno-wrapv" } */
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;