double atan(double); const double pi = 4*atan(1.0); should yield an error. The constraints on constant expressions prohibit evaluated function calls. This is a regression in 3.4.
Confirmed.
Roger -- Would you care to take a look at this regression? -- Mark
This is a front-end issue of not telling the middle-end (fold) that it does not want the functions expanded at this point.
Proposed patch here: http://gcc.gnu.org/ml/gcc-patches/2004-06/msg00332.html
Subject: Bug 14649 CVSROOT: /cvs/gcc Module name: gcc Changes by: sayle@gcc.gnu.org 2004-06-07 18:49:38 Modified files: gcc : ChangeLog c-typeck.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: pr14649-1.c Log message: PR c/14649 * c-typeck.c (require_constant_value, require_constant_elements): Move declarations to the top of the file. (build_function_call): If we require a constant value, fold with fold_initializer. If the result is a constant, and the function wasn't called using __builtin_foo, issue a pedantic warning. (build_unary_op): If we require a constant value, fold tree with fold_initializer. (build_binary_op): Use require_constant_value to determine whether to call fold or fold_initializer. * gcc.dg/pr14649-1.c: New test case. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.3863&r2=2.3864 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-typeck.c.diff?cvsroot=gcc&r1=1.310&r2=1.311 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3819&r2=1.3820 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr14649-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 14649 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: sayle@gcc.gnu.org 2004-06-08 17:15:10 Modified files: gcc : ChangeLog c-typeck.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: pr14649-1.c Log message: PR c/14649 * c-typeck.c (require_constant_value, require_constant_elements): Move declarations to the top of the file. (build_function_call): If we require a constant value, fold with fold_initializer. If the result is a constant, and the function wasn't called using __builtin_foo, issue a pedantic warning. (build_unary_op): If we require a constant value, fold tree with fold_initializer. (build_binary_op): Use require_constant_value to determine whether to call fold or fold_initializer. * gcc.dg/pr14649-1.c: New test case. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.482&r2=2.2326.2.483 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.272.2.8&r2=1.272.2.9 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.200&r2=1.3389.2.201 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr14649-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.4.1
Fixed.