[Bug fortran/60057] New: bind(C): multi-dimensional arrays have incompatible types

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Feb 4 11:04:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60057

            Bug ID: 60057
           Summary: bind(C): multi-dimensional arrays have incompatible
                    types
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: diagnostic, lto
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org

As can be seen with

make check-gfortran RUNTESTFLAGS="--target_board=unix/-flto
dg.exp=bind_c_vars.f90"

FAIL: gfortran.dg/bind_c_vars.f90  -O0  (test for excess errors)
...

which is because LTO warns that

/space/rguenther/src/svn/trunk/gcc/testsuite/gfortran.dg/bind_c_vars_driver.c:12:5:
warning: type of 'myF90Array2D' does not match original declaration [enabled by
default]
/space/rguenther/src/svn/trunk/gcc/testsuite/gfortran.dg/bind_c_vars.f90:16:0:
note: previously declared here
/space/rguenther/src/svn/trunk/gcc/testsuite/gfortran.dg/bind_c_vars_driver.c:11:5:
warning: type of 'myF90Array3D' does not match original declaration [enabled by
default]
/space/rguenther/src/svn/trunk/gcc/testsuite/gfortran.dg/bind_c_vars.f90:15:0:
note: previously declared here

which effectively means that assignments in GIMPLE between those arrays
would be invalid (not array members but whole arrays).  Not sure if we
can create a testcase that will eventually ICE though.  Usually the above
also means that the arrays use different alias sets but that's safe here
because the alias set of an array is that of its element (and those are
compatible here).

The issue is that in C a[2][3] is ARRAY_TYPE <ARRAY_TYPE <...> > but
GFortran represents a(2)(3) as 1D ARRAY_TYPE <...> and thus both types
are not structurally equivalent (which is why LTO warns).

Not sure if this case is motivation enough to treat arrays structurally
the same if their overall size is the same.



More information about the Gcc-bugs mailing list