[Bug c++/80294] [5/6/7 Regression] ICE with constexpr and inheritance
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80294 Markus Trippelsdorf changed: What|Removed |Added Keywords||ice-on-valid-code Summary|[C++1z] ICE with constexpr |[5/6/7 Regression] ICE with |and inheritance |constexpr and inheritance --- Comment #5 from Markus Trippelsdorf --- 5/6/7 all segfault with -std=c++14, 4.9 rejects the testcase. Clang and icpc accept the code.
[Bug c++/80294] [5/6/7 Regression] ICE with constexpr and inheritance
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80294 Richard Biener changed: What|Removed |Added Priority|P3 |P2 Target Milestone|--- |5.5
[Bug c++/80294] [5/6/7 Regression] ICE with constexpr and inheritance
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80294 --- Comment #6 from Markus Trippelsdorf --- (gdb) l 1704/* FIXME speed this up, it's taking 16% of compile time on sieve testcase. */ 1705 1706bool 1707reduced_constant_expression_p (tree t) 1708{ 1709 switch (TREE_CODE (t)) 1710{ 1711case 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 0x0081e676 in reduced_constant_expression_p (t=0x76ea9a80) at /home/markus/gcc/gcc/cp/constexpr.c:1719 1719if (!reduced_constant_expression_p (elt)) (gdb) p elt $2 = (tree) 0x0 (gdb) l 1714 1715case 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) 1719if (!reduced_constant_expression_p (elt)) 1720 return false; 1721 return true; 1722 1723default: (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 = 0x76eb7ab0, 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;
[Bug c++/80294] [5/6/7 Regression] ICE with constexpr and inheritance
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80294 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org, ||jason at gcc dot gnu.org --- Comment #7 from Jakub Jelinek --- {.value_=} looks broken to me. It has been added by /* We fell off the end of the CONSTRUCTOR, so insert a new entry at the end. */ insert: { constructor_elt ce = { index, NULL_TREE }; vec_safe_insert (CONSTRUCTOR_ELTS (*valp), idx, ce); cep = CONSTRUCTOR_ELT (*valp, idx);
[Bug c++/80294] [5/6/7 Regression] ICE with constexpr and inheritance
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80294 --- Comment #8 from Jakub Jelinek --- ICE started with r218220.
[Bug c++/80294] [5/6/7 Regression] ICE with constexpr and inheritance
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80294 Markus Trippelsdorf changed: What|Removed |Added CC||nathan at gcc dot gnu.org --- Comment #9 from Markus Trippelsdorf --- This was added as an PR79141 fix. CCing Nathan.
[Bug c++/80294] [5/6/7 Regression] ICE with constexpr and inheritance
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80294 --- Comment #10 from Markus Trippelsdorf --- I've posted the simple patch here: https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00132.html
[Bug c++/80294] [5/6/7 Regression] ICE with constexpr and inheritance
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80294 --- Comment #11 from Markus Trippelsdorf --- (In reply to Markus Trippelsdorf from comment #9) > This was added as an PR79141 fix. CCing Nathan. Sorry, wrong PR (too many tabs open). I meant PR70393.
[Bug c++/80294] [5/6/7 Regression] ICE with constexpr and inheritance
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80294 --- Comment #12 from Jakub Jelinek --- r234636 just moved that, the constructor_elt ce = { index, NULL_TREE }; being pushed had there been before Nathan's patch too.
[Bug c++/80294] [5/6/7 Regression] ICE with constexpr and inheritance
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80294 --- Comment #13 from Markus Trippelsdorf --- (In reply to Jakub Jelinek from comment #12) > r234636 just moved that, the constructor_elt ce = { index, NULL_TREE }; > being pushed had there been before Nathan's patch too. But checking for valid elt when using FOR_EACH_CONSTRUCTOR_VALUE (*, *, elt) is used elsewhere, too. I don't see why it shouldn't be used here.
[Bug c++/80294] [5/6/7 Regression] ICE with constexpr and inheritance
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80294 --- Comment #14 from Jakub Jelinek --- I don't know what it means to have NULL elt and it looks weird to me, but I'm not a C++ FE maintainer, I assume Jason and/or Nathan will review your patch and know what it means. Just grepping through FOR_EACH_CONSTRUCTOR_VALUE reveals that many don't really accept NULL elements (e.g. use TREE_TYPE on the elements), while some others could cope with it (e.g. when value_dependent_expression_p or type_dependent_expression_p is called on it).
[Bug c++/80294] [5/6/7 Regression] ICE with constexpr and inheritance
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80294 --- Comment #15 from Markus Trippelsdorf --- I only looked at a small random sample. So yes, you are right and I retract my patch, because the majority doesn't expect a NULL elt.
[Bug c++/80294] [5/6/7 Regression] ICE with constexpr and inheritance
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80294 --- Comment #16 from Jakub Jelinek --- It can be context-specific, NULL elts valid only in some CONSTRUCTORs, e.g. during constexpr processing or whatever. In any case it would be good to understand if it is intentional and what it means.
[Bug c++/80294] [5/6/7 Regression] ICE with constexpr and inheritance
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80294 Jason Merrill changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
[Bug c++/80294] [5/6/7 Regression] ICE with constexpr and inheritance
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80294 --- Comment #17 from Jason Merrill --- Author: jason Date: Tue Apr 11 21:07:32 2017 New Revision: 246858 URL: https://gcc.gnu.org/viewcvs?rev=246858&root=gcc&view=rev Log: PR c++/80294 - ICE with constexpr and inheritance. * constexpr.c (reduced_constant_expression_p): A null constructor element is non-constant. (cxx_eval_indirect_ref): Don't VERIFY_CONSTANT before returning an empty base. Added: trunk/gcc/testsuite/g++.dg/cpp1y/constexpr-empty3.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/constexpr.c