SPREAD and UNPACK not accepted in constant expressions

SPREAD and UNPACK not accepted in constant expressions

Harald的头像

Hello all,

it appears that SPREAD and UNPACK are still not accepted in constant expressions:

program ifort_unpack
implicit none
integer, parameter :: set(5) = (/ 11,12,13,14,15 /)
integer, parameter :: sel(2) = (/ 12,14 /)
logical, parameter :: mask(size(set)) = &
any (spread (set,2,size(sel)) == &
spread (sel,1,size(set)), dim=2)
integer :: i
integer, parameter :: idx(size(set)) = &
unpack (vector = (/ (i,i=1,size(set)) /), &
mask = mask, &
field = 0 )
print *, idx
end program ifort_unpack

% ifort -V ifort-unpack.f90
Intel(R) Fortran Compiler XE for applications running on IA-32, Version 13.0.1.117 Build 20121010
Copyright (C) 1985-2012 Intel Corporation. All rights reserved.
FOR NON-COMMERCIAL USE ONLY

Intel(R) Fortran 13.0-2074
ifort-unpack.f90(6): error #6263: This intrinsic function is invalid in constant expressions. [SPREAD]
any (spread (set,2,size(sel)) == &
------------^
ifort-unpack.f90(7): error #6263: This intrinsic function is invalid in constant expressions. [SPREAD]
spread (sel,1,size(set)), dim=2)
------------^
ifort-unpack.f90(10): error #6263: This intrinsic function is invalid in constant expressions. [UNPACK]
unpack (vector = (/ (i,i=1,size(set)) /), &
-------^
compilation aborted for ifort-unpack.f90 (code 1)

I could not find any corresponding restriction in the F2k3 and F2k8 draft, so I assume
that there should be none. (If I remember correctly, it was illegal for SPREAD in F95)

Harald

2 帖子 / 0 new
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项.
Steve Lionel (Intel)的头像

This is a F2003 feature we have not completely implemented yet - transformational intrinsics in constant expressions.

Steve

登陆并发表评论。