diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-03-22 15:40:59 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-03-22 15:40:59 +0100 |
commit | a15ffa22b5b541a385e509649dc39db59492bcdb (patch) | |
tree | 8606dad0f353d85630d41e4b1e4b709dce94fd2e /gcc/doc | |
parent | 29e0246c68efd4b68f9593ff26b3c123fb05161d (diff) | |
download | gcc-a15ffa22b5b541a385e509649dc39db59492bcdb.zip gcc-a15ffa22b5b541a385e509649dc39db59492bcdb.tar.gz gcc-a15ffa22b5b541a385e509649dc39db59492bcdb.tar.bz2 |
re PR c++/87481 (Endless loop with optimisation in C++17)
PR c++/87481
* doc/invoke.texi (-fconstexpr-ops-limit=): Document.
* c.opt (-fconstexpr-ops-limit=): New option.
* constexpr.c (struct constexpr_ctx): Add constexpr_ops_count member.
(cxx_eval_constant_expression): When not skipping, not constant class
or location wrapper, increment *ctx->constexpr_ops_count and if it is
above constexpr_loop_nest_limit, diagnose failure.
(cxx_eval_outermost_constant_expr): Add constexpr_ops_count and
initialize ctx.constexpr_ops_count to its address.
(is_sub_constant_expr): Likewise.
* g++.dg/cpp1y/constexpr-87481.C: New test.
From-SVN: r269874
Diffstat (limited to 'gcc/doc')
-rw-r--r-- | gcc/doc/invoke.texi | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 0a94151..4735b0a 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -210,7 +210,7 @@ in the following sections. @gccoptlist{-fabi-version=@var{n} -fno-access-control @gol -faligned-new=@var{n} -fargs-in-order=@var{n} -fchar8_t -fcheck-new @gol -fconstexpr-depth=@var{n} -fconstexpr-loop-limit=@var{n} @gol --fno-elide-constructors @gol +-fconstexpr-ops-limit=@var{n} -fno-elide-constructors @gol -fno-enforce-eh-specs @gol -fno-gnu-keywords @gol -fno-implicit-templates @gol @@ -2525,6 +2525,16 @@ Set the maximum number of iterations for a loop in C++14 constexpr functions to @var{n}. A limit is needed to detect infinite loops during constant expression evaluation. The default is 262144 (1<<18). +@item -fconstexpr-ops-limit=@var{n} +@opindex fconstexpr-ops-limit +Set the maximum number of operations during a single constexpr evaluation. +Even when number of iterations of a single loop is limited with the above limit, +if there are several nested loops and each of them has many iterations but still +smaller than the above limit, or if in a body of some loop or even outside +of a loop too many expressions need to be evaluated, the resulting constexpr +evaluation might take too long. +The default is 33554432 (1<<25). + @item -fdeduce-init-list @opindex fdeduce-init-list Enable deduction of a template type parameter as |