Hi,

The loop-expression loops endless in c++14's case for cases the
statement-list isn't constant.

Bug 63996 - Infinite loop in invalid C++14 constexpr fn

ChangeLog

2014-12-12  Kai Tietz  <kti...@redhat.com>

    PR c++/63996
    * constexpr.c (cxx_eval_loop_expr): Don't loop
    endless on none-constant expression.


2014-12-12  Kai Tietz  <kti...@redhat.com>

    PR c++/63996
    * g++.dg/cpp1y/pr63996.C: New file.

Tested for x86_64-w64-mingw32.  Ok for apply?

Regards,
Kai

New testcase in g++.dg/cpp1y as pr63996.C

// { dg-do compile { target c++14 } }

constexpr int
foo (int i)
{
  int a[i] = { };
}

constexpr int j = foo (1); // { dg-error "is not a constant expression" }


Index: constexpr.c
===================================================================
--- constexpr.c (Revision 218570)
+++ constexpr.c (Arbeitskopie)
@@ -2841,7 +2870,7 @@ cxx_eval_loop_expr (const constexpr_ctx *ctx, tree
     {
       cxx_eval_statement_list (ctx, body,
                               non_constant_p, overflow_p, jump_target);
-      if (returns (jump_target) || breaks (jump_target))
+      if (returns (jump_target) || breaks (jump_target) || *non_constant_p)
        break;
     }
   if (breaks (jump_target))

Reply via email to