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

ifort/ifx bug with allocation of logical array

hkvzjal
New Contributor I
1,048 Views

Hi,

I found a small bug with both ifort and ifx compilers when trying to allocate a logical array by negating on a source array. Here a minimal reproducer:

logical, allocatable :: mask(:), nmask(:)
allocate( mask(5) , source = .false. )
allocate( nmask(5), source = .not.mask(:))
end

This prompts:

error #5082: Syntax error, found '.' when expecting one of: ( <IDENTIFIER> <CHAR_CON_KIND_PARAM> <CHAR_NAM_KIND_PARAM> <CHARACTER_CONSTANT> <INTEGER_CONSTANT> ...
allocate( nmask(5), source = .not.mask(:))

Thanks,

0 Kudos
6 Replies
andrew_4619
Honored Contributor III
1,029 Views

And this compiles OK so I would agree  there has to be a problem here. The new front end needs a tweak...

allocate( nmask(5), source = ( .not.mask(:) ) )
FortranFan
Honored Contributor III
997 Views

 

 

Presumably

 

nmask = .not. mask

 

still works???!!!

0 Kudos
andrew_4619
Honored Contributor III
979 Views

Yes indeed that work ok I will note that  these variants give different errors. It is just not parsing the .not. correctly 

allocate( nmask(5), source = .not.mask(:)) ! error #5082
allocate( nmask(5), source = .not.mask) ! errors #6764 and #8155

 

Ron_Green
Moderator
963 Views

This is an interesting case.  I am opening a bug report.  Thanks for finding this.

Ron_Green
Moderator
953 Views

bug ID is CMPLRLLVM-54326


Devorah_H_Intel
Moderator
121 Views

This issue was fixed, and the fix is available in ifx 2025.

0 Kudos
Reply