[Bug fortran/83705] [8 Regression] ICE/wrong code with large values of REPEAT after revision r256284
jb at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Jan 6 11:33:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83705
--- Comment #2 from Janne Blomqvist <jb at gcc dot gnu.org> ---
With the following patch the testcase works:
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 3e5abd4..d68975c 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -6084,8 +6084,8 @@ gfc_simplify_repeat (gfc_expr *e, gfc_expr *n)
(8 * 2**20 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 > 8388608)
+ //return NULL;
result = gfc_get_character_expr (e->ts.kind, &e->where, NULL, nlen);
for (size_t i = 0; i < (size_t) ncop; i++)
diff --git a/gcc/fortran/trans-const.c b/gcc/fortran/trans-const.c
index 028e6d2..2d84ba7 100644
--- a/gcc/fortran/trans-const.c
+++ b/gcc/fortran/trans-const.c
@@ -89,7 +89,7 @@ gfc_build_string_const (int length, const char *s)
non-default character kinds. */
tree
-gfc_build_wide_string_const (int kind, int length, const gfc_char_t *string)
+gfc_build_wide_string_const (int kind, gfc_charlen_t length, const gfc_char_t
*string)
{
int i;
tree str, len;
@@ -141,7 +141,7 @@ gfc_conv_string_init (tree length, gfc_expr * expr)
{
gfc_char_t *s;
HOST_WIDE_INT len;
- int slen;
+ gfc_charlen_t slen;
tree str;
bool free_s = false;
diff --git a/gcc/fortran/trans-const.h b/gcc/fortran/trans-const.h
index 39693bb..d51c564 100644
--- a/gcc/fortran/trans-const.h
+++ b/gcc/fortran/trans-const.h
@@ -45,7 +45,7 @@ tree gfc_conv_constant_to_tree (gfc_expr *);
void gfc_conv_constant (gfc_se *, gfc_expr *);
tree gfc_build_string_const (int, const char *);
-tree gfc_build_wide_string_const (int, int, const gfc_char_t *);
+tree gfc_build_wide_string_const (int, gfc_charlen_t, const gfc_char_t *);
tree gfc_build_cstring_const (const char *);
tree gfc_build_localized_cstring_const (const char *);
Of course, commenting out the part in simplify.c makes the repeat_7.f90 test
fail. Also, when compiling the testcase in this PR the compiler uses 1.7 GB
RAM, so I do think it makes sense to have *some* limit where we give up and
defer to runtime.
The problem thus is that some code somewhere doesn't like that simplification
fails. If I don't comment out the simplify.c part I get the ICE:
f951: internal compiler error: Segmentation fault
0xcd4a3f crash_signal
../../trunk-git/gcc/toplev.c:325
0x6973ba add_init_expr_to_sym
../../trunk-git/gcc/fortran/decl.c:1748
0x6a0aa0 variable_decl
../../trunk-git/gcc/fortran/decl.c:2589
0x6a0aa0 gfc_match_data_decl()
../../trunk-git/gcc/fortran/decl.c:5692
0x6fe7a9 match_word_omp_simd
../../trunk-git/gcc/fortran/parse.c:93
0x701f3e match_word
../../trunk-git/gcc/fortran/parse.c:376
0x701f3e decode_statement
../../trunk-git/gcc/fortran/parse.c:376
0x703fc1 next_free
../../trunk-git/gcc/fortran/parse.c:1226
0x703fc1 next_statement
../../trunk-git/gcc/fortran/parse.c:1458
0x705abb parse_spec
../../trunk-git/gcc/fortran/parse.c:3836
0x708023 parse_progunit
../../trunk-git/gcc/fortran/parse.c:5649
0x7096c4 gfc_parse_file()
../../trunk-git/gcc/fortran/parse.c:6189
0x751e7f gfc_be_parse_file
../../trunk-git/gcc/fortran/f95-lang.c:204
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
More information about the Gcc-bugs
mailing list