Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28367 Discussions

Bug report: nested implied-do initialization

Harper__John
Beginner
497 Views

I think the program below is valid Fortran, but ifort won't compile it.
However if in line 4 U(J) is changed to J the program compiles and runs with
ifort, printing

1 2 2 3 3 3

Both versions initialize the array A with nested implied-do loops. Two
other compilers, gfortran and g95, compile and run either version of the
program and print the same output as above.

The offending 7-line program with its compile-time messages and what I hope
is enough information about my system from the uname -a command:

greta-pt[~/Jfh] % cat initbug.f90
program test
implicit none
integer :: INNER, J
integer,parameter :: U(3) = [ 1,2,3 ]
integer :: A(6) = [ ( ( J, INNER = 1,U(J) ), J = 1,3 ) ]
print "(999I2)",A
end program test
greta-pt[~/Jfh] % ifort -V initbug.f90
Intel(R) Fortran Intel(R) 64 Compiler for applications running on Intel(R)
64, Version 19.1.2.254 Build 20200623
Copyright (C) 1985-2020 Intel Corporation. All rights reserved.

Intel(R) Fortran 19.1-1648
initbug.f90(5): error #6973: This is not a valid initialization expression.
[J]
integer :: A(6) = [ ( ( J, INNER = 1,U(J) ), J = 1,3 ) ]
----------------------------^
initbug.f90(5): error #6973: This is not a valid initialization expression.
integer :: A(6) = [ ( ( J, INNER = 1,U(J) ), J = 1,3 ) ]
----------------------------^
compilation aborted for initbug.f90 (code 1)
greta-pt[~/Jfh] % uname -a
Linux greta-pt.ecs.vuw.ac.nz 5.7.7-arch1-1 #1 SMP PREEMPT Wed, 01 Jul 2020
14:53:16 +0000 x86_64 GNU/Linux
greta-pt[~/Jfh] %

Labels (1)
0 Kudos
1 Reply
Steve_Lionel
Honored Contributor III
476 Views

I agree that this is valid source - NAG Fortran also compiles it without error. I checked with the standard and there's nothing wrong with U(J) as a scalar-int-expr in an ac-implied-do-control (R775 in F2018, R474 in F2008.) Please submit a bug report through the Intel Online Service Center.

0 Kudos
Reply