Bug 14649 - [3.4 Regression] atan(1.0) should not be a constant expression
Summary: [3.4 Regression] atan(1.0) should not be a constant expression
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.4.0
: P2 minor
Target Milestone: 3.4.1
Assignee: roger
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2004-03-19 11:47 UTC by Joseph S. Myers
Modified: 2004-10-30 21:09 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.0.0
Known to fail:
Last reconfirmed: 2004-03-19 14:28:27


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph S. Myers 2004-03-19 11:47:23 UTC
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 Andrew Pinski 2004-03-19 14:28:27 UTC
Confirmed.
Comment 2 Mark Mitchell 2004-05-28 22:18:18 UTC
Roger --

Would you care to take a look at this regression?

-- Mark
Comment 3 Andrew Pinski 2004-05-28 22:22:04 UTC
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 roger 2004-06-07 14:17:47 UTC
Proposed patch here: http://gcc.gnu.org/ml/gcc-patches/2004-06/msg00332.html
Comment 5 GCC Commits 2004-06-07 18:49:46 UTC
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 GCC Commits 2004-06-08 17:15:12 UTC
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 Andrew Pinski 2004-06-08 17:52:49 UTC
Fixed.