diff options
author | Janne Blomqvist <jb@gcc.gnu.org> | 2018-02-01 09:41:03 +0200 |
---|---|---|
committer | Janne Blomqvist <jb@gcc.gnu.org> | 2018-02-01 09:41:03 +0200 |
commit | eae4d8fbb529d67428a2b0eba407b975ee13e7d1 (patch) | |
tree | 0cc2f53da00d6b4a6fd019523f0f6a4bcab9e36b /gcc/fortran/simplify.c | |
parent | 22149e37f7537843947003b4c7df76b69dd287ac (diff) | |
download | gcc-eae4d8fbb529d67428a2b0eba407b975ee13e7d1.zip gcc-eae4d8fbb529d67428a2b0eba407b975ee13e7d1.tar.gz gcc-eae4d8fbb529d67428a2b0eba407b975ee13e7d1.tar.bz2 |
PR 83705 Repeat with large values
This patch fixes the regression by increasing the limit where we fall
back to runtime to 2**28 elements, which is the same limit where
previous releases failed. The are still bugs in the runtime
evaluation, so in many cases longer characters will still fail, so
print a warning message.
Regtested on x86_64-pc-linux-gnu.
gcc/fortran/ChangeLog:
2018-02-01 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/83705
* simplify.c (gfc_simplify_repeat): Increase limit for deferring
to runtime, print a warning message.
gcc/testsuite/ChangeLog:
2018-02-01 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/83705
* gfortran.dg/repeat_7.f90: Catch warning message.
From-SVN: r257281
Diffstat (limited to 'gcc/fortran/simplify.c')
-rw-r--r-- | gcc/fortran/simplify.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 2458956..324f858 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -6121,12 +6121,16 @@ gfc_simplify_repeat (gfc_expr *e, gfc_expr *n) len = e->value.character.length; gfc_charlen_t nlen = ncop * len; - /* Here's a semi-arbitrary limit. If the string is longer than 32 MB - (8 * 2**20 elements * 4 bytes (wide chars) per element) defer to + /* Here's a semi-arbitrary limit. If the string is longer than 1 GB + (2**28 elements * 4 bytes (wide chars) per element) defer to runtime instead of consuming (unbounded) memory and CPU at compile time. */ - if (nlen > 8388608) - return NULL; + if (nlen > 268435456) + { + gfc_warning_now (0, "Evaluation of string longer than 2**28 at %L" + " deferred to runtime, expect bugs", &e->where); + return NULL; + } result = gfc_get_character_expr (e->ts.kind, &e->where, NULL, nlen); for (size_t i = 0; i < (size_t) ncop; i++) |