Hi!

The following testcase ICEs since TYPE_POLYMORPHIC_P macro has been
changed to allow being used only on RECORD_TYPE/UNION_TYPE.
This particular spot wasn't adjusted.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk?

2026-01-03  Jakub Jelinek  <[email protected]>

        PR c++/123347
        * constexpr.cc (potential_constant_expression_1): Check for
        CLASS_TYPE_P before using TYPE_POLYMORPHIC_P on TREE_TYPE (e).

        * g++.dg/cpp1y/pr123347.C: New test.

--- gcc/cp/constexpr.cc.jj      2026-01-02 11:51:24.742507592 +0100
+++ gcc/cp/constexpr.cc 2026-01-02 12:26:27.884941874 +0100
@@ -12075,6 +12075,7 @@ potential_constant_expression_1 (tree t,
            && strict
            && !TYPE_P (e)
            && !type_dependent_expression_p (e)
+           && CLASS_TYPE_P (TREE_TYPE (e))
            && TYPE_POLYMORPHIC_P (TREE_TYPE (e)))
           {
             if (flags & tf_error)
--- gcc/testsuite/g++.dg/cpp1y/pr123347.C.jj    2026-01-02 12:33:39.324657964 
+0100
+++ gcc/testsuite/g++.dg/cpp1y/pr123347.C       2026-01-02 12:32:58.044354893 
+0100
@@ -0,0 +1,8 @@
+// PR c++/123347
+// { dg-do compile { target c++14 } }
+
+#include <typeinfo>
+
+int a;
+template <int N>
+const std::type_info &v = typeid (a);

        Jakub

Reply via email to