> Gesendet: Freitag, 20. August 2021 um 14:01 Uhr > Von: "Tobias Burnus" <tob...@codesourcery.com> > On 20.08.21 12:53, Harald Anlauf wrote: > > > I played with variations of the testcase by specifying illegal > > substring bounds, but all these cases were caught in a different > > spot with similar error messages. > > I can confirm this. – I think in order to reduce the clutter, the > diagnostic probably should be removed.
I am unable to prove that we will never that check. So how about: diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index eaabbffca4d..04722a8640c 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -4552,27 +4552,13 @@ substring_has_constant_len (gfc_expr *e) if (istart <= iend) { - char buffer[21]; - if (istart < 1) - { - sprintf (buffer, HOST_WIDE_INT_PRINT_DEC, istart); - gfc_error ("Substring start index (%s) at %L below 1", - buffer, &ref->u.ss.start->where); - return false; - } - /* For deferred strings use end index as proxy for length. */ if (e->ts.deferred) length = iend; else length = gfc_mpz_get_hwi (ref->u.ss.length->length->value.integer); - if (iend > length) - { - sprintf (buffer, HOST_WIDE_INT_PRINT_DEC, iend); - gfc_error ("Substring end index (%s) at %L exceeds string length", - buffer, &ref->u.ss.end->where); - return false; - } + + gcc_assert (istart >= 1 && iend <= length); length = iend - istart + 1; } else Or skip the gcc_assert and cross fingers... (we then would not even need to verify ref->u.ss.length in that depth). Harald