-
Notifications
You must be signed in to change notification settings - Fork 97
Description
Background
I'd like to test parallel builds of neural-fortran with LLVM flang-new
22.0.0git (the current main branch of LLVM). If my search of neural-fortran is correct, then flang-new
now supports every multi-image feature that neural-fortran uses, including this_image()
, num_images()
, co_broadcast
, and co_sum
. Please let me know if I missed any features.
An apparent standard violation blocks building the current main branch of neural-fortran with the LLVM flang-new
compiler and with the NAG nagfor
compilers; whereas the GCC gfortran
and Intel ifx
compilers allow the relevant code. The feature involved was allowed by the Fortran 2003 standard but disallowed in subsequent standards.
Issue
The output of fpm test --compiler flang-new --flag -O3
includes the following:
error: Semantic errors in ././src/nf/nf_optimizers.f90
./././src/nf/nf_optimizers.f90:321:48: error: Result of pure function may not be both polymorphic and ALLOCATABLE
class(optimizer_base_type), allocatable :: res
^^^
<ERROR> Compilation failed for object " src_nf_nf_optimizers.f90.o "
Similarly, the output of fpm test --compiler nagfor --flag -O3
includes the following:
Error: ././src/nf/nf_optimizers.f90, line 341: Result variable of pure function GET_OPTIMIZER_BY_NAME is polymorphic allocatable
Errors in declarations, no further processing for GET_OPTIMIZER_BY_NAME
Compiler Bug Reports and the Standard
I reported this as GCC Bug 78640 in 2016, but it hasn't been fixed yet. The Fortran 2023 standard clause 4.5.3 states, "Fortran 2003 permitted the function result of a pure function to be a polymorphic allocatable variable, to have a polymorphic allocatable ultimate component, or to be finalizable by an impure final subroutine. These are not permitted by this document."