Bug 14649 - [3.4 Regression] atan(1.0) should not be a constant expression
Bug#: 14649 Product:  gcc Version: 3.4.0
Host:  Target:  Build: 
Status: RESOLVED Severity: minor Priority: P2
Resolution: FIXED Assigned To: roger@eyesopen.com Reported By: jsm28@gcc.gnu.org
Component: c Target Milestone: 3.4.1
Summary: [3.4 Regression] atan(1.0) should not be a constant expression
Keywords:  accepts-invalid
Opened: 2004-03-19 11:47
Description:   Last confirmed: 2004-03-19 14:28 Opened: 2004-03-19 11:47
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.

------- Comment #1 From Andrew Pinski 2004-03-19 14:28 -------
Confirmed.

------- Comment #2 From Mark Mitchell 2004-05-28 22:18 -------
Roger --

Would you care to take a look at this regression?

-- Mark

------- Comment #3 From Andrew Pinski 2004-05-28 22:22 -------
This is a front-end issue of not telling the middle-end (fold) that it does not
want the functions 
expanded at this point.

------- Comment #4 From roger@eyesopen.com 2004-06-07 14:17 -------
Proposed patch here: http://gcc.gnu.org/ml/gcc-patches/2004-06/msg00332.html

------- Comment #5 From CVS Commits 2004-06-07 18:49 -------
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


------- Comment #6 From CVS Commits 2004-06-08 17:15 -------
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


------- Comment #7 From Andrew Pinski 2004-06-08 17:52 -------
Fixed.