[Bug c++/94490] Ternary expression with 3 consts is “not” a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94490 Marek Polacek changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #8 from Marek Polacek --- Fixed in GCC 11.3 and 12.1.
[Bug c++/94490] Ternary expression with 3 consts is “not” a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94490 --- Comment #7 from CVS Commits --- The releases/gcc-11 branch has been updated by Marek Polacek : https://gcc.gnu.org/g:5746f9199c2b8f0d679f13e3a48d6f8546a974f6 commit r11-9350-g5746f9199c2b8f0d679f13e3a48d6f8546a974f6 Author: Marek Polacek 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 : fake_tuple_size_v)' is not a constant expression because cxx_constant_value in expand_integer_pack gets *(0 ? VIEW_CONVERT_EXPR(fake_tuple_size_v) : VIEW_CONVERT_EXPR(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. (cherry picked from commit 9af081003f9c19f33457e0ed1aa14a764f462c3c)
[Bug c++/94490] Ternary expression with 3 consts is “not” a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94490 --- Comment #6 from CVS Commits --- The trunk branch has been updated by Marek Polacek : https://gcc.gnu.org/g:9af081003f9c19f33457e0ed1aa14a764f462c3c commit r12-5712-g9af081003f9c19f33457e0ed1aa14a764f462c3c Author: Marek Polacek 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 : fake_tuple_size_v)' is not a constant expression because cxx_constant_value in expand_integer_pack gets *(0 ? VIEW_CONVERT_EXPR(fake_tuple_size_v) : VIEW_CONVERT_EXPR(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.
[Bug c++/94490] Ternary expression with 3 consts is “not” a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94490 --- Comment #5 from Marek Polacek --- Patch finally posted: https://gcc.gnu.org/pipermail/gcc-patches/2021-December/585932.html
[Bug c++/94490] Ternary expression with 3 consts is “not” a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94490 Marek Polacek changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org --- Comment #4 from Marek Polacek --- Nice, thanks. I'll take this one then; hopefully I'll get to it soon.
[Bug c++/94490] Ternary expression with 3 consts is “not” a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94490 Patrick Palka changed: What|Removed |Added Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Last reconfirmed||2021-05-27 CC||ppalka at gcc dot gnu.org --- Comment #3 from Patrick Palka --- Marek, it looks like your https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94489#c2 patch also fixes this PR.
[Bug c++/94490] Ternary expression with 3 consts is “not” a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94490 ensadc at mailnesia dot com changed: What|Removed |Added CC||ensadc at mailnesia dot com --- Comment #2 from ensadc at mailnesia dot com --- reduced & modified: ``` template constexpr int fake_tuple_size_v = 3; template struct intseq {}; template using genseq = intseq<__integer_pack(N)...>; template> struct arith_result { }; template auto Mul(const T&) { return [](auto) { return arith_result> { }; }(0); } auto x = Mul(0); ```
[Bug c++/94490] Ternary expression with 3 consts is “not” a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94490 Marek Polacek changed: What|Removed |Added CC||mpolacek at gcc dot gnu.org --- Comment #1 from Marek Polacek --- In expand_integer_pack tsubst_copy_and_build produces *(0 ? tuple_size_v : tuple_size_v) and cxx_constant_value complains, because we turn tuple_size_v into '2' and so we're dereferencing an INTEGER_CST.