https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107695

            Bug ID: 107695
           Summary: Non conforming shape during assignment is not detected
                    at run-time
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: edouard.ca...@univ-rennes1.fr
  Target Milestone: ---

Created attachment 53900
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53900&action=edit
Fortran test program which reveals the bug

At run-time, the attached program leads to memory problems (only detected by
valgrind).

It is compiled by the following command:
  $ gfortran -fbounds-check -g -o test test.f90

The bug occurs at least for GCC versions from 8.5 to 12.2

In the following assignment:
  z(ind,ind) = data(:,:)
I thought that data is recognized as a scalar (shape is [1,1]) and its value
spread to the four elements of z. This is not the case.

However:
  z(ind,ind) = data(1,1)
gives the correct result as expected.

Of course, the problem cannot be detected at compile-time since both 'z' and
'data' arrays are allocatable.

Reply via email to