Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

ICE on vector section in DATA statement

Harald1
New Contributor II
1,552 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
1,527 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
1,510 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
1,496 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
1,471 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
1,453 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
1,452 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
1,438 Views

Interesting. You learn something new every day !

0 Kudos
TobiasK
Moderator
1,251 Views

@Harald1


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


0 Kudos
Reply