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

ICE on vector section in DATA statement

Harald1
New Contributor II
935 Views

Hello,

the following code ICEs with current ifort/ifx:

block data
  implicit none
  integer :: b(2,1)
  data b( 1 ,1)   / 11 / ! OK
  data b([2],1)   / 21 / ! ICE
  common /com/ b
end block data

program test
  integer :: b(2,1)
  common /com/ b
  print *, b
end program test

I get:

% ifort ifort-data-vector-section.f90
ifort-data-vector-section.f90: catastrophic error: **Internal compiler error: segmentation violation signal raised** Please report this error along with the circumstances in which it occurred in a Software Problem Report.  Note: File and line given may not be explicit cause of this error.
compilation aborted for ifort-data-vector-section.f90 (code 1)

 Interestingly, replacing line 5 by:

  data b([2],[1]) / 21 / ! works

 the code compiles and prints the correct result.

As far as I can tell, the sample code is valid F2018 (and likely F2008 and F2003).

 

0 Kudos
8 Replies
andrew_4619
Honored Contributor III
910 Views

Hmm I don't know if using an array constructor as an array index is valid or not, it is hard to see a usage for that.

It also seems strange to mixed a "recent" f2003 square bracket constructor with the obsolete block data feature. Anyway I will watch this post with interest to see how it develops. An ICE is clearly a compiler problem is should either compile or throw an error message for invalid code.

 

0 Kudos
TobiasK
Moderator
893 Views

Hi @Harald1


thanks for the reproducer, actually it also happens without the block construct and without COMMON. I escalated it to our internal team.


Best

Tobias


0 Kudos
Steve_Lionel
Honored Contributor III
879 Views

Of course. vector subscripts are allowed in an array reference, but, and I was surprised by this, they are also allowed in a DATA statement. "An array section is equivalent to the sequence of its array elements in array element order."

0 Kudos
jimdempseyatthecove
Honored Contributor III
854 Views

Steve,

Using OP's example, the following derivative:

block data
  implicit none
  integer :: b(3,1)
  data b( 2 ,1)   / 1 / ! b(2,1) = 1
  data b([1,3],1)   / 2, 3 / ! b(1,1) = 2; b(3,1) = 3
  common /com/ b
end block data

Is that permitted to obtain the results in the comments?

 

Jim Dempsey

0 Kudos
Steve_Lionel
Honored Contributor III
836 Views

Yes, that is allowed. Here is what NAG does:

D:\Projects>type t.f90
block data
  implicit none
  integer :: b(3,1)
  data b( 2 ,1)   / 1 / ! b(2,1) = 1
  data b([1,3],1)   / 2, 3 / ! b(1,1) = 2; b(3,1) = 3
  common /com/ b
end block data
program test
integer :: b(3,1)
common /com/ b
print *, b
end
D:\Projects>nagfor -o t.exe t.f90
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7120
[NAG Fortran Compiler normal termination]

D:\Projects>t.exe
 2 1 3
0 Kudos
jimdempseyatthecove
Honored Contributor III
835 Views

This is feature is quite neat. I can think of a few times that this would have come in handy.

Will keep this in mind for the next time.

 

Jim Dempsey

 

0 Kudos
andrew_4619
Honored Contributor III
821 Views

Interesting. You learn something new every day !

0 Kudos
TobiasK
Moderator
634 Views

@Harald1


good news, the fix is implemented and will be part of the second next release, 2024.1.


0 Kudos
Reply