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

ifort rejects nested array constructor despite typespec

Harald1
New Contributor II
1,025 Views

Intel 2021.5.0 rejects the following code - which is accepted by NAG:

program p
  integer, parameter :: a(*) = [1]
  print *, [ real :: + a  ] ! OK
  print *, [ real :: +[a] ] ! rejected
  print *, [ real :: +[1] ] ! rejected
end

 The compiler gives:

ifort-nested-ctor.f90(4): error #8209: If type specification is omitted, each element in an
array-constructor must have the same type and kind type parameters.
 print *, [ real :: +[a] ] ! rejected
---------------------^
ifort-nested-ctor.f90(5): error #8209: If type specification is omitted, each element in an
array-constructor must have the same type and kind type parameters.
 print *, [ real :: +[1] ] ! rejected
---------------------^
compilation aborted for ifort-nested-ctor.f90 (code 1)

Somehow the unary + sign in front of the constructor confuses the compiler.

 

Thanks,

Harald

0 Kudos
1 Solution
Barbara_P_Intel
Moderator
993 Views

Thank for reporting this with such a small reproducer. We appreciate that!

I filed a bug report, CMPLRIL0-34589. I'll let you know its progress to a fix.



View solution in original post

0 Kudos
3 Replies
Barbara_P_Intel
Moderator
994 Views

Thank for reporting this with such a small reproducer. We appreciate that!

I filed a bug report, CMPLRIL0-34589. I'll let you know its progress to a fix.



0 Kudos
Barbara_P_Intel
Moderator
822 Views

This issue with the erroneous error message is fixed in ifx 2023.0.0 and ifort 2021.8.0 that were released in December as part of the oneAPI HPC Toolkit. Please check it out!

 

0 Kudos
Harald1
New Contributor II
797 Views

Yes, it is indeed fixed.  Thanks!

 

0 Kudos
Reply