[Bug c++/107574] [10/11/12/13 Regression] ICE: tree check in cp_fold_convert with ptr to member field cast inside a class not completed and inherent since r9-50-gd760b06868d660bc
mpolacek at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jan 31 23:42:44 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107574
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Are we sure we want to accept this? I know we did, but that seems like an
accident (cp_fold_convert wasn't checking same_type_p).
Essentially it comes down to the fact that we're attempting to evaluate a
PTRMEM_CST in a class that hasn't been completed yet, but that doesn't work:
/* We can't lower this until the class is complete. */
if (!COMPLETE_TYPE_P (DECL_CONTEXT (member)))
return cst;
and then this unlowered PTRMEM_CST is used as EXPR in
tree op1 = build_nop (ptrdiff_type_node, expr);
and we crash in cp_fold_convert which gets type=ptrdiff_type_node,
expr=PTRMEM_CST and does
else if (TREE_CODE (expr) == PTRMEM_CST
&& same_type_p (TYPE_PTRMEM_CLASS_TYPE (type),
PTRMEM_CST_CLASS (expr)))
where TYPE_PTRMEM_CLASS_TYPE (type) is going to crash. We could just add a
TYPE_PTRMEM_P check and go back to the GCC 7 error.
More information about the Gcc-bugs
mailing list