https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106856
--- Comment #7 from anlauf at gcc dot gnu.org --- (In reply to anlauf from comment #6) > Submitted: https://gcc.gnu.org/pipermail/fortran/2023-March/059003.html As discussed in this thread, this version of the patch works for subroutine s1 (x) class(*) :: x allocatable :: x dimension :: x(:) if (allocated (x)) print *, size (x) end subroutine s2 (x) class(*) :: x allocatable :: x(:) if (allocated (x)) print *, size (x) end but still ICEs for the variations / line permutations subroutine s3 (x) class(*) :: x(:) allocatable :: x if (allocated (x)) print *, size (x) end subroutine s4 (x) class(*) :: x dimension :: x(:) allocatable :: x if (allocated (x)) print *, size (x) end I think Mikael's findings in the thread fix this.