Hi!

The assert there assumes we never evaluate a statement list to
DEBUG_BEGIN_STMT, but it breaks appart when a BIND_EXPR with a typedef in it
has some DEBUG_BEGIN_STMTs in it and nothing else (without -g it is just
empty STATEMENT_LIST inside of the BIND_EXPR).  We want to return void_node
in that case.

THere is nothing interesting about DEBUG_BEGIN_STMT for constexpr
evaluation, it doesn't change any values, so let's just ignore them
and the assert is then unnecessary.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2018-01-09  Jakub Jelinek  <ja...@redhat.com>

        PR c++/83734
        * constexpr.c (cxx_eval_statement_list): Ignore DEBUG_BEGIN_STMTs
        in STATEMENT_LIST.  Remove unneeded assert.

        * g++.dg/cpp0x/pr83734.C: New test.

--- gcc/cp/constexpr.c.jj       2018-01-04 00:43:16.108702767 +0100
+++ gcc/cp/constexpr.c  2018-01-08 13:38:22.531365873 +0100
@@ -3851,6 +3851,8 @@ cxx_eval_statement_list (const constexpr
   for (i = tsi_start (t); !tsi_end_p (i); tsi_next (&i))
     {
       tree stmt = tsi_stmt (i);
+      if (TREE_CODE (stmt) == DEBUG_BEGIN_STMT)
+       continue;
       r = cxx_eval_constant_expression (ctx, stmt, false,
                                        non_constant_p, overflow_p,
                                        jump_target);
@@ -3859,14 +3861,6 @@ cxx_eval_statement_list (const constexpr
       if (returns (jump_target) || breaks (jump_target))
        break;
     }
-  /* Make sure we don't use the "result" of a debug-only marker.  That
-     would be wrong.  We should be using the result of the previous
-     statement, or NULL if there isn't one.  In practice, this should
-     never happen: the statement after the marker should override the
-     result of the marker, so its value shouldn't survive in R.  Now,
-     should that ever change, we'll need some fixing here to stop
-     markers from modifying the generated executable code.  */
-  gcc_checking_assert (!r || TREE_CODE (r) != DEBUG_BEGIN_STMT);
   return r;
 }
 
--- gcc/testsuite/g++.dg/cpp0x/pr83734.C.jj     2018-01-08 13:40:00.843390108 
+0100
+++ gcc/testsuite/g++.dg/cpp0x/pr83734.C        2018-01-08 13:39:19.278379863 
+0100
@@ -0,0 +1,6 @@
+// PR c++/83734
+// { dg-do compile { target c++11 } }
+// { dg-options "-g -O2" }
+
+struct A { constexpr A () { typedef int T; } };
+A a;

        Jakub

Reply via email to