Update concepts branch to revision 131834
[official-gcc.git] / gcc / testsuite / gcc.dg / builtins-8.c
blobbe17774d5265a85a6e05158166ffa7f23e1a7bce
1 /* Copyright (C) 2003, 2006 Free Software Foundation.
3 Verify that built-in math function constant folding of functions
4 with one constant argument is correctly performed by the compiler.
6 Written by Roger Sayle, 30th March 2003. */
8 /* { dg-do run } */
9 /* { dg-options "-O2 -ffast-math" } */
11 extern void abort(void);
12 extern double pow(double, double);
13 extern double sqrt(double);
14 extern double cbrt(double);
16 void test(double x)
18 if (pow(x,-1.0) != 1.0/x)
19 abort ();
21 if (pow(x,2.0) != x*x)
22 abort ();
24 if (pow(x,-2.0) != 1.0/(x*x))
25 abort ();
27 if (pow(x,0.5) != sqrt(x))
28 abort ();
30 if (pow(x,1.0/3.0) != cbrt(x))
31 abort ();
34 int main()
36 test (1.0);
37 test (2.0);
38 return 0;