+2018-01-31 Jason Merrill <jason@redhat.com>
+ Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/83993
+ * constexpr.c (cxx_eval_outermost_constant_expr): Build NOP_EXPR
+ around non-constant ADDR_EXPRs rather than clearing TREE_CONSTANT
+ on ADDR_EXPR.
+
2018-01-31 Jakub Jelinek <jakub@redhat.com>
PR c++/83993
return error_mark_node;
else if (non_constant_p && TREE_CONSTANT (r))
{
- /* This isn't actually constant, so unset TREE_CONSTANT. */
- if (EXPR_P (r))
+ /* This isn't actually constant, so unset TREE_CONSTANT.
+ Don't clear TREE_CONSTANT on ADDR_EXPR, as the middle-end requires
+ it to be set if it is invariant address, even when it is not
+ a valid C++ constant expression. Wrap it with a NOP_EXPR
+ instead. */
+ if (EXPR_P (r) && TREE_CODE (r) != ADDR_EXPR)
r = copy_node (r);
else if (TREE_CODE (r) == CONSTRUCTOR)
r = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (r), r);
2018-01-31 Jakub Jelinek <jakub@redhat.com>
+ PR c++/83993
+ * g++.dg/init/pr83993-2.C: New test.
+
PR c++/83993
* g++.dg/init/pr83993-1.C: New test.
* g++.dg/cpp0x/pr83993.C: New test.