This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ Patch] PR 68087
- From: Markus Trippelsdorf <markus at trippelsdorf dot de>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Wed, 25 Nov 2015 16:59:49 +0100
- Subject: Re: [C++ Patch] PR 68087
- Authentication-results: sourceware.org; auth=none
- References: <5655D718 dot 20209 at oracle dot com>
On 2015.11.25 at 16:43 +0100, Paolo Carlini wrote:
> Hi,
>
> for this small 5/6 regression (an ICE) Markus suggests in the audit trail to
> protect the tree_to_shwi call with tree_fits_shwi_p. I tweaked a bit his
> suggestion adopting a pattern already used, eg, in the parser, and
> successfully tested it in trunk. I suppose it could make sense to also fix
> the issue in the branch, if we can do that safely, and I also propose below
> a variant for that (cxx_eval_array_reference is slightly different in the
> branch). Ok?
>
> ////////////////////////////
> /cp
> 2015-11-25 Markus Trippelsdorf <markus@trippelsdorf.de>
> Paolo Carlini <paolo.carlini@oracle.com>
>
> PR c++/68087
> * constexpr.c (cxx_eval_array_reference): Use tree_fits_shwi_p before
> tree_to_shwi to avoid ICEs.
>
> /testsuite
> 2015-11-25 Markus Trippelsdorf <markus@trippelsdorf.de>
> Paolo Carlini <paolo.carlini@oracle.com>
>
> PR c++/68087
> * g++.dg/cpp0x/constexpr-array13.C: New.
> Index: cp/constexpr.c
> ===================================================================
> --- cp/constexpr.c (revision 230865)
> +++ cp/constexpr.c (working copy)
> @@ -1799,8 +1799,8 @@ cxx_eval_array_reference (const constexpr_ctx *ctx
> gcc_unreachable ();
> }
>
> - i = tree_to_shwi (index);
> - if (i < 0)
> + if (!tree_fits_shwi_p (index)
> + || (i = tree_to_shwi (index)) < 0)
Last time Richard pointed out that:
if (wi::lts_p (index, 0))
is more idiomatic.
--
Markus