[Bug c++/104230] Non-type template arguments of reference and pointer type fail when initialized by pointer to member operator

anton at socialhacker dot com gcc-bugzilla@gcc.gnu.org
Mon Jan 31 19:37:51 GMT 2022


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

--- Comment #2 from anton at socialhacker dot com ---
Hmm, sorry, still learning the bugzilla UI.  I thought that patch would be
attached to my next comment.  I don't believe that patch is a solution to the
problem.  It was just a way I was able to make progress debugging the issue.  I
followed that patch with one that allowed GCC to mangle the resulting
POINTER_PLUS_EXPR.  But the end result was that the two template instantiations
were not considered the same (as far as __is_same was concerned).

I'm pretty sure that the problem is upstream instead of downstream from the
location where the diagnostic is generated (in invalid_tparm_referent_p).  And
I've been working my way backwards into the parser, but it's much slower going
for me.  I've found where the two different parse trees are generated for the
two different version of the template parameters.  But they happen in such
different portions of the parser I'm not sure at all how to have them generate
the same tree eventually, which is I'm guessing the right answer to the
problem.

That is, instead of generating a COMPONENT_REF for the accepted form, and a
POINTER_PLUS_EXPR for the rejected form, GCC should probably be generating
COMPONENT_REF for both.  But I think it's forgotten the required information to
do that conversion from POINTER_PLUS_EXPR by the time it's needed.

I'm guessing someone who knows the parser side well might have a better chance
at seeing how that should be done.


More information about the Gcc-bugs mailing list