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

ICE related to ieee_arithmetic intrinsic module

machalot
Novice
1,036 Views

I wrote a test program to help me understand the ieee_arithmetic module.  An intermediate version of my code (which is not expected to compile successfully) suffered an internal compiler error.  I'm using Intel Fortran 2019 in Redhat Enterprise Linux 7.9:

 

 

$ ifort --version
ifort (IFORT) 19.0.5.281 20190815
Copyright (C) 1985-2019 Intel Corporation.  All rights reserved.

 

 

Error message:

 

 

$ ifort ieee_values_test.f90 
ieee_values_test.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 ieee_values_test.f90 (code 1)

 

 

Code (filename is ieee_values_test.f90):

 

 

program ieee_values_check
use, intrinsic :: ieee_arithmetic
implicit none

!real :: x
real, dimension(10) :: x
real, parameter     :: nan = ieee_value( x, ieee_negative_inf )

!x = 0.0
x = [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, nan, 7.0, 8.0, 9.0, nan ]
print *
print *, x
print *, "Is finite?   ", ieee_is_finite( x )
print *, "Is NaN?      ", ieee_is_nan( x )
print *, "Is unordered?", ieee_unordered( x, x )

x = ieee_value( x, ieee_negative_inf )
print *
print *, x
print *, "Is finite?   ", ieee_is_finite( x )
print *, "Is NaN?      ", ieee_is_nan( x )
print *, "Is unordered?", ieee_unordered( x, x )

x = ieee_value( x, ieee_negative_inf )
print *
print *, x
print *, "Is finite?   ", ieee_is_finite( x )
print *, "Is NaN?      ", ieee_is_nan( x )
print *, "Is unordered?", ieee_unordered( x, x )

x = ieee_value( x, ieee_quiet_nan )
print *
print *, x
print *, "Is finite?   ", ieee_is_finite( x )
print *, "Is NaN?      ", ieee_is_nan( x )
print *, "Is unordered?", ieee_unordered( x, x )

x = ieee_value( x, ieee_signaling_nan )
print *
print *, x
print *, "Is finite?   ", ieee_is_finite( x )
print *, "Is NaN?      ", ieee_is_nan( x )
print *, "Is unordered?", ieee_unordered( x, x )

print *

end program ieee_values_check

 

 

  

7 Replies
JohnNichols
Valued Contributor III
1,009 Views

Screenshot 2024-03-18 165736.png

It will not build in VS 2022 with IFX - latest.  Is there a switch to be set? 

 

Same errors in modern IFORT, I would update and fix the errors. 

machalot
Novice
1,008 Views

Thanks for taking a look.  The code I posted is an intermediate version that doesn't compile successfully.  I am just trying to report the internal compiler error to Intel as requested by their error message.

But since you asked, here is the version that worked before I tried to get fancy:

program ieee_values_check
use, intrinsic :: ieee_arithmetic
implicit none

real :: x

x = 0.0

print *
print *, x
print *, "Is finite?   ", ieee_is_finite( x )
print *, "Is NaN?      ", ieee_is_nan( x )
print *, "Is unordered?", ieee_unordered( x, x )

x = ieee_value( x, ieee_negative_inf )
print *
print *, x
print *, "Is finite?   ", ieee_is_finite( x )
print *, "Is NaN?      ", ieee_is_nan( x )
print *, "Is unordered?", ieee_unordered( x, x )

x = ieee_value( x, ieee_negative_inf )
print *
print *, x
print *, "Is finite?   ", ieee_is_finite( x )
print *, "Is NaN?      ", ieee_is_nan( x )
print *, "Is unordered?", ieee_unordered( x, x )

x = ieee_value( x, ieee_quiet_nan )
print *
print *, x
print *, "Is finite?   ", ieee_is_finite( x )
print *, "Is NaN?      ", ieee_is_nan( x )
print *, "Is unordered?", ieee_unordered( x, x )

x = ieee_value( x, ieee_signaling_nan )
print *
print *, x
print *, "Is finite?   ", ieee_is_finite( x )
print *, "Is NaN?      ", ieee_is_nan( x )
print *, "Is unordered?", ieee_unordered( x, x )

print *

end program ieee_values_check
0 Kudos
Ron_Green
Moderator
995 Views

odd, on linux with the latest ifort and ifx I don't see any problems.   v2019 is no longer support btw

 

ifx -what -V ieee_values_test.f90 
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2024.0.0 Build 20231017
Copyright (C) 1985-2023 Intel Corporation. All rights reserved.

 Intel(R) Fortran 24.0-1238.2
GNU ld version 2.39-9.fc38
rwgreen@orcsle153:~/quad/monday$ ./a.out
 
  0.0000000E+00
 Is finite?    T
 Is NaN?       F
 Is unordered? F
 
      -Infinity
 Is finite?    F
 Is NaN?       F
 Is unordered? F
 
      -Infinity
 Is finite?    F
 Is NaN?       F
 Is unordered? F
 
            NaN
 Is finite?    F
 Is NaN?       T
 Is unordered? T
 
            NaN
 Is finite?    F
 Is NaN?       T
 Is unordered? T
 

 

0 Kudos
Ron_Green
Moderator
908 Views

My mistake, I see now that you have 2 versions of this code.  I only tried the second example.  Both had the same filename, I think that is what threw me, I didn't realize they were 2 different codes.  

 

So you have 2 errors in the original example.

 

1) line 7

real, parameter     :: nan = ieee_value( x, ieee_negative_inf )

repro1.f90(7): error #9131: This generic function from an intrinsic module is not permitted in a constant expression.   [IEEE_VALUE]

real, parameter     :: nan = ieee_value( x, ieee_negative_inf )

-----------------------------^

 

The NAG compiler agrees.  For this parameter assignment you have to have the RHS expression must be constant expression.  The NAG compiler agrees:

NAG Fortran Compiler Release 7.1(Hanzomon) Build 7125
Error: repro1.f90, line 7: Reference to non-intrinsic function IEEE_VALUE_R via generic IEEE_VALUE in constant expression
Errors in declarations, no further processing for IEEE_VALUES_CHECK
[NAG Fortran Compiler error termination, 1 error]

NAG stops at this point and doesn't compile further.

 

2) ifx continues compiling and finds this error

repro1.f90(10): error #6366: The shapes of the array expressions do not conform.   [X]
x = [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, nan, 7.0, 8.0, 9.0, nan ]
^

Which is correct.  You declared X as a fixed size static array

real, dimension(10) :: x

but the RHS array constructor has 11 elements.  This array assignment is non-conforming.  Since the array X is static and not allocatable we cannot realloc the LHS to conform to the RHS. 

 

0 Kudos
Ron_Green
Moderator
907 Views

I should say that the NAG error message is more exact (as usual).  Ours could use a rewording, the "constant expression" is misleading.

0 Kudos
machalot
Novice
879 Views

Hi Ron, thank you for your attention on this.  I should have better emphasized in my original post, I am not in need of Fortran debugging support for this code, I already have it updated and working.  I am only reporting the internal compiler error since that should not happen (even when I attempt to compile invalid Fortran) and it is requested by the compiler's error message.  I intentionally posted the code exactly as it was when the internal compiler error occurred. 

If the response from Intel is that v2019 is no longer supported, and this error doesn't occur in later versions, then maybe this post is moot.

0 Kudos
Ron_Green
Moderator
861 Views

we've implemented a lot of Fortran 2008 and 2018 since the 2019 version. those internal errors were common before or during our modern fortran implementation was underway.    We do like to hear about ICEs and get those fixed, so thank you for bringing it here.  

0 Kudos
Reply