gcc/fortran/ChangeLog:
PR fortran/105230
* expr.cc (find_array_section): Correct logic to avoid NULL
pointer dereference on invalid array section.
gcc/testsuite/ChangeLog:
PR fortran/105230
* gfortran.dg/pr105230.f90: New test.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
(cherry picked from commit
0acdbe29f66017fc5cca40dcbd72a0dd41491d07)
if ((begin && begin->expr_type != EXPR_CONSTANT)
|| (finish && finish->expr_type != EXPR_CONSTANT)
|| (step && step->expr_type != EXPR_CONSTANT)
- || (!begin && !lower)
- || (!finish && !upper))
+ || !lower
+ || !upper)
{
t = false;
goto cleanup;
--- /dev/null
+! { dg-do compile }
+! PR fortran/105230 - ICE in find_array_section
+! Contributed by G.Steinmetz
+
+program p
+ integer, parameter :: a(:) = [1, 2] ! { dg-error "deferred shape" }
+ print *, reshape([3, 4], a(1:2))
+end