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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>:

https://gcc.gnu.org/g:9af081003f9c19f33457e0ed1aa14a764f462c3c

commit r12-5712-g9af081003f9c19f33457e0ed1aa14a764f462c3c
Author: Marek Polacek <pola...@redhat.com>
Date:   Sat Nov 6 18:10:39 2021 -0400

    c++: Fix bogus error with __integer_pack [PR94490]

    Here we issue a bogus:

    error: '(0 ? fake_tuple_size_v<int> : fake_tuple_size_v<int>)' is not a
constant expression

    because cxx_constant_value in expand_integer_pack gets

    *(0 ? VIEW_CONVERT_EXPR<const int>(fake_tuple_size_v) :
VIEW_CONVERT_EXPR<const int>(fake_tuple_size_v))

    which is a REFERENCE_REF_P and we evaluate its operand to 3, so we end
    up with *3 and that fails.  Sounds like we need to get rid of the
    REFERENCE_REF_P then.  That is what tsubst_copy_and_build/INDIRECT_REF
    will do:

            if (REFERENCE_REF_P (t))
              {
                /* A type conversion to reference type will be enclosed in
                   such an indirect ref, but the substitution of the cast
                   will have also added such an indirect ref.  */
                r = convert_from_reference (r);
              }

    so I think it's reasonable to call instantiate_non_dependent_expr_sfinae.

            PR c++/94490

    gcc/cp/ChangeLog:

            * pt.c (expand_integer_pack): Call
            instantiate_non_dependent_expr_sfinae.

    gcc/testsuite/ChangeLog:

            * g++.dg/ext/integer-pack5.C: New test.

Reply via email to