[PATCH] Fix PR21595
Roger Sayle
roger@eyesopen.com
Tue May 17 02:36:00 GMT 2005
On Mon, 16 May 2005, Richard Guenther wrote:
> 2005-05-16 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.
This is OK for mainline, and after a few days for the gcc-4_0 branch
as it is a regression from 3.4.
We should be able to consider array references other than 0 to also
be constant, but I appreciate there are middle-end representation
issues that may complicate things. "foo" + 0 = "foo", but "foo" + 1
!= "oo", when expressed in terms of STRING_CST.
> int main()
> {
> if (! __builtin_constant_p (&"Hello"[0]))
> link_error();
> }
My maintainer-sense is tingling that it may be preferable to add
a "return 0;" at the end of main in this testcase. I can't quite
put my finger on why, as this is a link rather than an execution
test, but given that exiting main without a return value isn't a
part of this test, there's no reason to anger the coding style gods.
This tweak to the testcase is preapproved.
Thanks,
Roger
--
More information about the Gcc-patches
mailing list