This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/80294] [5/6/7 Regression] ICE with constexpr and inheritance
- From: "trippels at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 04 Apr 2017 07:52:21 +0000
- Subject: [Bug c++/80294] [5/6/7 Regression] ICE with constexpr and inheritance
- Auto-submitted: auto-generated
- References: <bug-80294-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80294
--- Comment #6 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
(gdb) l
1704 /* FIXME speed this up, it's taking 16% of compile time on sieve
testcase. */
1705
1706 bool
1707 reduced_constant_expression_p (tree t)
1708 {
1709 switch (TREE_CODE (t))
1710 {
1711 case PTRMEM_CST:
1712 /* Even if we can't lower this yet, it's constant. */
1713 return true;
(gdb) p t
$1 = (tree) 0x0
(gdb) up
#1 0x000000000081e676 in reduced_constant_expression_p (t=0x7ffff6ea9a80) at
/home/markus/gcc/gcc/cp/constexpr.c:1719
1719 if (!reduced_constant_expression_p (elt))
(gdb) p elt
$2 = (tree) 0x0
(gdb) l
1714
1715 case CONSTRUCTOR:
1716 /* And we need to handle PTRMEM_CST wrapped in a CONSTRUCTOR. */
1717 tree elt; unsigned HOST_WIDE_INT idx;
1718 FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (t), idx, elt)
1719 if (!reduced_constant_expression_p (elt))
1720 return false;
1721 return true;
1722
1723 default:
(gdb) p idx
$3 = 0
(gdb) p *t->constructor.elts
$4 = {
m_vecpfx = {
m_alloc = 4,
m_using_auto_storage = 0,
m_num = 1
},
m_vecdata = {{
index = 0x7ffff6eb7ab0,
value = 0x0
}}
}
So perhaps simply:
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 3ca356071810..9ee794d5bf37 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -1716,7 +1716,7 @@ reduced_constant_expression_p (tree t)
/* And we need to handle PTRMEM_CST wrapped in a CONSTRUCTOR. */
tree elt; unsigned HOST_WIDE_INT idx;
FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (t), idx, elt)
- if (!reduced_constant_expression_p (elt))
+ if (elt && !reduced_constant_expression_p (elt))
return false;
return true;