This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH for c++/69379 (ICE with PTRMEM_CST wrapped in NOP_EXPR)
- From: Marek Polacek <polacek at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 22 Jan 2016 23:07:34 +0100
- Subject: Re: C++ PATCH for c++/69379 (ICE with PTRMEM_CST wrapped in NOP_EXPR)
- Authentication-results: sourceware.org; auth=none
- References: <20160121182532 dot GF25528 at redhat dot com> <56A1282A dot 8020904 at redhat dot com> <20160122172010 dot GG25528 at redhat dot com> <56A29342 dot 3010301 at redhat dot com>
On Fri, Jan 22, 2016 at 03:38:26PM -0500, Jason Merrill wrote:
> If we have a NOP_EXPR to the same type, we should strip it here.
This helps for the unreduced testcases in the PR, but not for the reduced one,
because for the reduced one, the types are not the same. One type is
struct
{
void Dict::<T461> (struct Dict *, T) * __pfn;
long int __delta;
}
and the second one
struct
{
void Dict::<T442> (struct Dict *) * __pfn;
long int __delta;
}
The NOP_EXPR in this case originated in build_reinterpret_cast_1:
7070 else if ((TYPE_PTRFN_P (type) && TYPE_PTRFN_P (intype))
7071 || (TYPE_PTRMEMFUNC_P (type) && TYPE_PTRMEMFUNC_P (intype)))
7072 return build_nop (type, expr);
So maybe the following patch is desirable, but it's not a complete fix :(.
Thanks,
2016-01-22 Marek Polacek <polacek@redhat.com>
PR c++/69379
* constexpr.c (cxx_eval_constant_expression) [NOP_EXPR]: When
converting PTRMEM_CST to the same type, strip nops.
diff --git gcc/cp/constexpr.c gcc/cp/constexpr.c
index 6b0e5a8..6fe5cbe 100644
--- gcc/cp/constexpr.c
+++ gcc/cp/constexpr.c
@@ -3619,6 +3619,11 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
if (TREE_CODE (op) == PTRMEM_CST
&& !TYPE_PTRMEM_P (type))
op = cplus_expand_constant (op);
+ if (TREE_CODE (op) == PTRMEM_CST
+ && tcode == NOP_EXPR
+ && same_type_ignoring_top_level_qualifiers_p (type,
+ TREE_TYPE (op)))
+ STRIP_NOPS (t);
if (POINTER_TYPE_P (type)
&& TREE_CODE (op) == INTEGER_CST
&& !integer_zerop (op))
Marek