2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.dg / fwrapv-2.c
blobcb4270e0ee2cc544a15670a0b68d1e860502e47c
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 main()
22 int x = INT_MAX;
24 if (test(x) != x)
25 abort ();
26 return 0;