https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98017
--- Comment #3 from anlauf at gcc dot gnu.org ---
Further reduced variant:
program p
implicit none
character(*), parameter :: exprs(1) = ['abc()']
print *, len (pack ( exprs , exprs(:)(:1) =='a'))
print *, len (pack (['abc()'],['abc()' (:1)]=='a'))
end
gcc-7 prints:
5
5
while 8 and newer print:
1
5
My debugging attempts so far suggest that this part of expr.c corrupts the
string length:
227 if (e->expr_type == EXPR_VARIABLE && e->rank > 0
228 && e->symtree->n.sym->attr.flavor == FL_PARAMETER)
229 gfc_simplify_expr (e, 1);
After gfc_simplify_expr (e, 1),
(gdb) p *e->ts.u.cl->length->value.integer._mp_d
$34 = 1
for the first variant, while we don't simplify for the second and keep
(gdb) p *e->ts.u.cl->length->value.integer._mp_d
$37 = 5