Bug 21595 - [4.0 Regression] __builtin_constant_p(&"Hello"[0]) is true for C but not for C++
Summary: [4.0 Regression] __builtin_constant_p(&"Hello"[0]) is true for C but not for C++
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.0.1
Assignee: Richard Biener
URL:
Keywords: missed-optimization
Depends on:
Blocks: 21619
  Show dependency treegraph
 
Reported: 2005-05-15 21:33 UTC by Richard Biener
Modified: 2005-05-27 18:08 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 3.4.0 4.1.0
Known to fail: 4.0.0
Last reconfirmed: 2005-05-15 21:47:03


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2005-05-15 21:33:05 UTC
... because of different representations are passed to fold_builtin_constant_p.
Comment 1 Richard Biener 2005-05-15 21:47:03 UTC
patch in testing
Comment 2 Andrew Pinski 2005-05-16 00:02:21 UTC
This is also a regression from 3.4.0.
Comment 3 Andrew Pinski 2005-05-16 00:04:04 UTC
Here is a compile time testcase:
int f[__builtin_constant_p(&"Hello"[0])?1:-1];
Comment 4 GCC Commits 2005-05-17 09:00:15 UTC
Subject: Bug 21595

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rguenth@gcc.gnu.org	2005-05-17 09:00:03

Modified files:
	gcc            : ChangeLog builtins.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/tree-ssa: builtin1.C 

Log message:
	2005-05-17  Richard Guenther  <rguenth@gcc.gnu.org>
	
	PR middle-end/21595
	* builtins.c (fold_builtin_constant_p): Handle
	&"string cst"[0] as constant.
	
	* g++.dg/tree-ssa/builtin1.C: New testcase.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.8814&r2=2.8815
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/builtins.c.diff?cvsroot=gcc&r1=1.461&r2=1.462
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5482&r2=1.5483
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/tree-ssa/builtin1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 5 Richard Biener 2005-05-27 18:08:02 UTC
Fixed for 4.0.1.