Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Comunicados
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 Discussões

ICE on vector section in DATA statement

Harald1
Novo colaborador II
1.553 Visualizações

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 Respostas
andrew_4619
Colaborador honorário III
1.528 Visualizações

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.

 

TobiasK
Moderador
1.511 Visualizações

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


Steve_Lionel
Colaborador honorário III
1.497 Visualizações

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."

jimdempseyatthecove
Colaborador honorário III
1.472 Visualizações

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

Steve_Lionel
Colaborador honorário III
1.454 Visualizações

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
jimdempseyatthecove
Colaborador honorário III
1.453 Visualizações

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

 

andrew_4619
Colaborador honorário III
1.439 Visualizações

Interesting. You learn something new every day !

TobiasK
Moderador
1.252 Visualizações

@Harald1


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


Responder