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

Simplification of ISHFTC may cause ICE

Harald1
New Contributor II
1,946 Views

The following snippet of invalid code crashes current ifort:

program p
  integer, parameter :: a = ishftc(1, 10, 0) ! ICE
! print *, ishftc(1, 10, 0)                  ! No ICE
end

I get:

Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.7.1 Build 20221019_000000
Copyright (C) 1985-2022 Intel Corporation.  All rights reserved.

 Intel(R) Fortran 2021.7.1-1776
ifort-ishftc.f90: catastrophic error: **Internal compiler error: floating point exception 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.

The SIZE argument is out of range; it must be positive.  But it shouldn't crash the compiler.

 

1 Solution
Barbara_P_Intel
Employee
1,205 Views

This second case is fixed now, too, in the compilers that were released this week. 

@Harald1,  it seems like you are a winner with this release, 2024.0!

View solution in original post

0 Kudos
14 Replies
JohnNichols
Valued Contributor III
1,911 Views

JohnNichols_0-1670785498799.png

If I search for ishftc, the Intel Fortran documentation explains, IMHO, why your call is wrong, I agree it should throw an error not an ICE. 

If I then tap on the model of bit data represented on the page, I get the above page, but the pictures refer to pages that no longer exist. 

Perhaps we could fix both problems. 

 

0 Kudos
Barbara_P_Intel
Employee
1,873 Views

I filed a bug report on the ICE, CMPLRLLVM-42645. I'll track and see when it's fixed.


0 Kudos
Barbara_P_Intel
Employee
1,869 Views

About the documentation ... I filed another bug, DOC-10657. What's missing are some formulas. The formulas show up okay in the .pdf version of the DGR (Developer Guide and Reference). Here's the first one.

Barbara_P_Intel_0-1670969822888.png

 

 

0 Kudos
Barbara_P_Intel
Employee
1,797 Views

The Fortran Developer Guide and Reference now properly shows the formulas. 

0 Kudos
Barbara_P_Intel
Employee
1,670 Views

Good News! This ICE is fixed in the upcoming release of ifx.


0 Kudos
Barbara_P_Intel
Employee
1,601 Views

The compiler with the fix to this ICE is available now as part of oneAPI 2023.1.

Give it a try!

 

0 Kudos
Harald1
New Contributor II
1,573 Views

Barbara,

I tried the new compiler.  The ICE is gone, but I believe the diagnostics could still be better, as it does not report that the SIZE argument shall be positive.

Consider the variation:

program p
  integer, parameter :: a = ishftc(1, 10, 0) ! invalid
  integer, parameter :: b = ishftc(1,  0, 0) ! invalid
end

This now compiles without warning, unless I add -stand:

% ifort ifort-ishftc.f90 -stand
ifort-ishftc.f90(2): warning #7317: Standard F2018 requires that the absolute value of SHIFT, the 2nd argument, be less than or equal to SIZE, the 3rd argument.   [ISHFTC]
  integer, parameter :: a = ishftc(1, 10, 0) ! invalid
----------------------------^

Note that it misses the second invalid declaration.  So the issue is only almost resolved....

Thanks,

Harald

 

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,570 Views

I wonder why Fortran uses a derivative of "shift" for this as opposed to (just about) everyone else using a derivative of "rotate".

I suspect ishftc is an abbreviation of IntegerShiftCircular, imho rotate would have been a better choice.

Also, other implementations permit bit counts that exceed BIT_SIZE (as internally they perform a MOD on the bitsize for rotate.

Jim Dempsey

 

0 Kudos
Steve_Lionel
Honored Contributor III
1,557 Views

"Circular shift" is also a common term - I hear that more than rotate. ISHFT and ISHFTC date from MIL-STD-1753 in the late 1970s.

0 Kudos
Barbara_P_Intel
Employee
1,492 Views

I'm checking with the resident Fortran language experts on the warning message.

Last time I checked abs (0) <= 0 was true. The second usage should be fine, no warning.

 

0 Kudos
Harald1
New Contributor II
1,484 Views

I'm sorry to bother you again, but regarding the second usage, let me quote from the F2018 draft standard:

16.9.104 ISHFTC (I, SHIFT [, SIZE])
...
Arguments.
...
SIZE (optional) shall be of type integer. The value of SIZE shall be positive and shall not exceed BIT_SIZE (I).
If SIZE is absent, it is as if it were present with the value of BIT_SIZE (I).

Note that "0" is not a positive number, so I disagree with your assessment, as does NAG:

NAG Fortran Compiler Release 7.1(Hanzomon) Build 7101
Warning: ifort-ishftc2.f90, line 2: Unused PARAMETER A
Error: ifort-ishftc2.f90, line 2: SIZE argument (0) to intrinsic ISHFTC out of range (1:32)
Warning: ifort-ishftc2.f90, line 3: Unused PARAMETER B
Error: ifort-ishftc2.f90, line 3: SIZE argument (0) to intrinsic ISHFTC out of range (1:32)
Errors in declarations, no further processing for P
[NAG Fortran Compiler error termination, 2 errors, 2 warnings]

 

Barbara_P_Intel
Employee
1,473 Views

Thanks for the clarification. I got tangled up in what the warning message reported which is not really correct. I filed a bug report to clarify the message and identify the problem in the second case, CMPLRLLVM-46728.

 

 

0 Kudos
Barbara_P_Intel
Employee
1,206 Views

This second case is fixed now, too, in the compilers that were released this week. 

@Harald1,  it seems like you are a winner with this release, 2024.0!

0 Kudos
Harald1
New Contributor II
1,193 Views

Yes, I now get a warning when specifying "-stand".

Great, thanks!

This makes us all winners!

 

0 Kudos
Reply