https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51961
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Harald Anlauf <anl...@gcc.gnu.org>: https://gcc.gnu.org/g:3b276fe0d22f9052657dbbffbb8ad6f8585bd304 commit r16-1528-g3b276fe0d22f9052657dbbffbb8ad6f8585bd304 Author: Harald Anlauf <anl...@gmx.de> Date: Sun Jun 15 21:09:28 2025 +0200 Fortran: fix checking of MOLD= in ALLOCATE statements [PR51961] In ALLOCATE statements where the MOLD= argument is present and is not scalar, and the allocate-object has an explicit-shape-spec, the standard does not require the ranks to agree. In that case we skip the rank check, but emit a warning if -Wsurprising is given. PR fortran/51961 gcc/fortran/ChangeLog: * resolve.cc (conformable_arrays): Use modified rank check when MOLD= expression is given. gcc/testsuite/ChangeLog: * gfortran.dg/allocate_with_mold_5.f90: New test.