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

            Bug ID: 90140
           Summary: Compiler incorrectly rejects use of pure functions in
                    DIMENSION attribute of procedure dummy arguments.
           Product: gcc
           Version: 8.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: matthew.thompson at nasa dot gov
  Target Milestone: ---

Created attachment 46199
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46199&action=edit
Reproducer of incorrect compilation

In porting a code that works with Intel Fortran, we started getting errors when
compiling with GCC 8.2 (and 8.3). We eventually whipped up a reproducer and
when run:

(340) $ gfortran -v -save-temps -c dimension_with_function.F90
Using built-in specs.
COLLECT_GCC=gfortran
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-8.2.0/configure --prefix=/ford1/local/gcc/gcc-8.2.0
--disable-multilib
Thread model: posix
gcc version 8.2.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-mtune=generic' '-march=x86-64'
 /ford1/local/gcc/gcc-8.2.0/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/f951
dimension_with_function.F90 -cpp=dimension_with_function.f90 -quiet -v
dimension_with_function.F90 -quiet -dumpbase dimension_with_function.F90
-mtune=generic -march=x86-64 -auxbase dimension_with_function -version
-fintrinsic-modules-path
/ford1/local/gcc/gcc-8.2.0/lib/gcc/x86_64-pc-linux-gnu/8.2.0/finclude -o
dimension_with_function.s
GNU Fortran (GCC) version 8.2.0 (x86_64-pc-linux-gnu)
        compiled by GNU C version 8.2.0, GMP version 6.1.0, MPFR version 3.1.4,
MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory
"/ford1/local/gcc/gcc-8.2.0/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /ford1/local/gcc/gcc-8.2.0/lib/gcc/x86_64-pc-linux-gnu/8.2.0/finclude
 /ford1/local/gcc/gcc-8.2.0/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include
 /usr/local/include
 /ford1/local/gcc/gcc-8.2.0/include
 /ford1/local/gcc/gcc-8.2.0/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include-fixed
 /usr/include
End of search list.
GNU Fortran2008 (GCC) version 8.2.0 (x86_64-pc-linux-gnu)
        compiled by GNU C version 8.2.0, GMP version 6.1.0, MPFR version 3.1.4,
MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
dimension_with_function.F90:27:30:

      character(32), dimension(this%get_ngas())     :: get_gases
                              1
Error: ‘get_ngas’ at (1) should be a FUNCTION
dimension_with_function.F90:27:30:

      character(32), dimension(this%get_ngas())     :: get_gases
                              1
Error: ‘get_ngas’ at (1) should be a FUNCTION
dimension_with_function.F90:39:37:

      real(wp), dimension(ncol,nlay,0:this%get_ngas()) :: col_gas
                                     1
Error: ‘get_ngas’ at (1) should be a FUNCTION

****

We have tested this reproducer with Intel 19.0.1 and NAG Fortran 6.2 and both
pass it. (A colleague notes that "NAG diagnoses that the PURE is required to do
this.")

I've also reproduced it on my macOS laptop with 8.3 but it's having issues at
the moment, so I'm reporting with the output of 8.2 on my Linux box (I've asked
the admins to install 8.3).

At present we have ugly workarounds where we paste "size(this%gas_names)" where
the declarations use "this%get_ngas()", but we'd prefer the function version
being used.

Reply via email to