https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101681

--- Comment #2 from Steven Sun <StevenSun2021 at hotmail dot com> ---
The root cause for this is that the compiler forbids constant folding when
involving PMF of an incomplete class.

https://gcc.gnu.org/git?p=gcc.git;a=blob;f=gcc/cp/expr.c;h=d16d1896f2ddd08264b389b02b9640cca332ec13;hb=refs/heads/master#l42

(gcc/cp/expr.c)
> 42   /* We can't lower this until the class is complete.  */
> 43         if (!COMPLETE_TYPE_P (DECL_CONTEXT (member)))
> 44           return cst;


If we comment this `if`, the constant folding will succeed at


(gcc/cp/expr.c)
> 67             expand_ptrmemfunc_cst (cst, &delta, &pfn);
> 68             cst = build_ptrmemfunc1 (type, delta, pfn);


solving everything.

Reply via email to