diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-03-08 21:05:21 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-03-08 21:05:21 +0100 |
commit | d259b234a301aa5c06ca78262ae814b3d8d0f1a5 (patch) | |
tree | 897ce2c797917765609e86f7a7499d60e9903ecf /gcc/cp | |
parent | 56aae4b7c0d088f2b1056b41ba1f502d93550020 (diff) | |
download | gcc-d259b234a301aa5c06ca78262ae814b3d8d0f1a5.zip gcc-d259b234a301aa5c06ca78262ae814b3d8d0f1a5.tar.gz gcc-d259b234a301aa5c06ca78262ae814b3d8d0f1a5.tar.bz2 |
re PR sanitizer/70135 (-fsanitize=undefined causes static_assert to fail)
PR c++/70135
* constexpr.c (cxx_eval_loop_expr): Forget saved values of SAVE_EXPRs
even after the last iteration of the loop.
* g++.dg/cpp1y/constexpr-loop4.C: New test.
* g++.dg/ubsan/pr70135.C: New test.
From-SVN: r234064
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/constexpr.c | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 54dd3ec..5906ceb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2016-03-08 Jakub Jelinek <jakub@redhat.com> + PR c++/70135 + * constexpr.c (cxx_eval_loop_expr): Forget saved values of SAVE_EXPRs + even after the last iteration of the loop. + * decl.c (duplicate_decls): Fix spelling - becuase -> because. 2016-03-07 Patrick Palka <ppalka@gcc.gnu.org> diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index f23e7c9..7f3edcf 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -3165,21 +3165,21 @@ cxx_eval_loop_expr (const constexpr_ctx *ctx, tree t, constexpr_ctx new_ctx = *ctx; tree body = TREE_OPERAND (t, 0); - while (true) + do { hash_set<tree> save_exprs; new_ctx.save_exprs = &save_exprs; cxx_eval_statement_list (&new_ctx, body, non_constant_p, overflow_p, jump_target); - if (returns (jump_target) || breaks (jump_target) || *non_constant_p) - break; /* Forget saved values of SAVE_EXPRs. */ for (hash_set<tree>::iterator iter = save_exprs.begin(); iter != save_exprs.end(); ++iter) new_ctx.values->remove (*iter); } + while (!returns (jump_target) && !breaks (jump_target) && !*non_constant_p); + if (breaks (jump_target)) *jump_target = NULL_TREE; |