Commit eae4d8fb by Janne Blomqvist

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
parent 22149e37
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.
2018-01-31 Jakub Jelinek <jakub@redhat.com> 2018-01-31 Jakub Jelinek <jakub@redhat.com>
PR fortran/84116 PR fortran/84116
......
...@@ -6121,12 +6121,16 @@ gfc_simplify_repeat (gfc_expr *e, gfc_expr *n) ...@@ -6121,12 +6121,16 @@ gfc_simplify_repeat (gfc_expr *e, gfc_expr *n)
len = e->value.character.length; len = e->value.character.length;
gfc_charlen_t nlen = ncop * len; gfc_charlen_t nlen = ncop * len;
/* Here's a semi-arbitrary limit. If the string is longer than 32 MB /* Here's a semi-arbitrary limit. If the string is longer than 1 GB
(8 * 2**20 elements * 4 bytes (wide chars) per element) defer to (2**28 elements * 4 bytes (wide chars) per element) defer to
runtime instead of consuming (unbounded) memory and CPU at runtime instead of consuming (unbounded) memory and CPU at
compile time. */ compile time. */
if (nlen > 8388608) if (nlen > 268435456)
return NULL; {
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); result = gfc_get_character_expr (e->ts.kind, &e->where, NULL, nlen);
for (size_t i = 0; i < (size_t) ncop; i++) for (size_t i = 0; i < (size_t) ncop; i++)
......
2018-02-01 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/83705
* gfortran.dg/repeat_7.f90: Catch warning message.
2018-01-31 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2018-01-31 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* lib/target-supports.exp (check_effective_target_comdat_group): * lib/target-supports.exp (check_effective_target_comdat_group):
......
...@@ -4,5 +4,5 @@ ...@@ -4,5 +4,5 @@
! compile time. ! compile time.
program p program p
character, parameter :: z = 'z' character, parameter :: z = 'z'
print *, repeat(z, huge(1_4)) print *, repeat(z, huge(1_4)) ! { dg-warning "Evaluation of string" }
end program p end program p
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment