[Bug c++/104278] ICE with class non-type template parameter with a value depdenent constexpr call

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Dec 20 16:09:40 GMT 2022


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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:49b6b7ac3314843466395c4a194aa178c80e64f5

commit r13-4807-g49b6b7ac3314843466395c4a194aa178c80e64f5
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Dec 20 11:09:11 2022 -0500

    c++: NTTP object wrapper substitution fixes [PR103346, ...]

    This patch fixes some issues with substitution into a C++20 template
    parameter object wrapper:

    * The first testcase demonstrates a situation where the same_type_p
      assert in relevant case of tsubst_copy doesn't hold, because (partial)
      substitution of {int,} into the wrapper's TREE_TYPE yields A<int> but
      substitution into the underlying TEMPLATE_PARM_INDEX is a nop due to
      tsubst's level==1/tf_partial early exit tests, hence TREE_TYPE in the
      latter case remains A<T>.  So this patch just gets rid of the assert;
      the type mismatch doesn't seem to be a problem in practice.

    * In the second testcase, dependent substitution into the underlying
      TEMPLATE_PARM_INDEX yields a CALL_EXPR with empty TREE_TYPE, which
      tsubst_copy doesn't expect.  This patch fixes this by handling empty
      TREE_TYPE the same way as a non-const TREE_TYPE.  Moreover, after
      this substitution we're left with a VIEW_CONVERT_EXPR wrapping a
      CALL_EXPR instead of a TEMPLATE_PARM_INDEX, which during the subsequent
      non-dependent substitution tsubst_copy doesn't expect either.  So
      this patch also relaxes tsubst_copy to accept such VIEW_CONVERT_EXPR
      too.

    * In the third testcase, we end up never resolving the call to
      f.modify() because tsubst_copy doesn't do overload resolution.
      This patch fixes this by moving the handling of these
      VIEW_CONVERT_EXPR wrappers from tsubst_copy to tsubst_copy_and_build.
      For good measure tsubst_copy_and_build should also handle
      REF_PARENTHESIZED_P wrappers instead of delegating to tsubst_copy.

            PR c++/103346
            PR c++/104278
            PR c++/102553

    gcc/cp/ChangeLog:

            * pt.cc (tsubst_copy) <case VIEW_CONVERT_EXPR>: Move the
            handling of C++20 template parameter object wrappers to ...
            (tsubst_copy_and_build) <case VIEW_CONVERT_EXPR>: ... here.
            Accept non-TEMPLATE_PARM_INDEX inner operand.  Handle empty
            TREE_TYPE on substituted inner operand.  Remove same_type_p
            assert.  Also handle REF_PARENTHESIZED_P VIEW_CONVERT_EXPRs.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/nontype-class52a.C: New test.
            * g++.dg/cpp2a/nontype-class53.C: New test.
            * g++.dg/cpp2a/nontype-class54.C: New test.
            * g++.dg/cpp2a/nontype-class55.C: New test.


More information about the Gcc-bugs mailing list