flang-compiler / f18

F18 is a front-end for Fortran intended to replace the existing front-end in the Flang compiler
230 stars 48 forks source link

sizeof pointer to derive type #1020

Open naromero77 opened 4 years ago

naromero77 commented 4 years ago

This compile-time error comes from a DOE science code. I suspect the problem is triggered by the intrinsic sizeof function operating on a pointer to a derived type.

home/naromero/mpich-3.3.2-test/bin/mpif90 -g -O3 -module-suffix .f18.mod  -fPIC -I/usr/include -D LIBRARY=1  -D  FFTW=1 -c -o src/parallelization/tiling/tiling.o src/parallelization/tiling/tiling.F90
src/parallelization/tiling/tiling.F90:1992:57: error: No explicit type declared for 'sizeof'

Here is the ling that it chokes on:

              local_part_tiles_mem=local_part_tiles_mem+SIZEOF(curr%part_x) 

and here is the declaration for the arguement:

    TYPE(particle_tile), POINTER :: curr

I am packaging up tiling.F90 along with the relevant modules. sizeof_type_pointer.tar.gz

klausler commented 4 years ago

Fortran doesn't have an intrinsic function named sizeof.

That call looks suspiciously like a macro invocation.

sscalpone commented 4 years ago

Intel and Gnu have a sizeof intrinsic.

https://software.intel.com/en-us/fortran-compiler-developer-guide-and-reference-sizeof

https://gcc.gnu.org/onlinedocs/gfortran/SIZEOF.html

Has this been standardized as C_SIZEOF?

naromero77 commented 4 years ago

Yep, those where the pages that I found. It seemed very much a C thing that got transplanted into Fortran.

This code is usually compiled with GNU or Intel.

naromero77 commented 4 years ago

Best that I can tell, there does not seem to be a macro defined in the code.