Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
公告
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 讨论

Simplification of ISHFTC may cause ICE

Harald1
新分销商 II
3,183 次查看

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 解答
Barbara_P_Intel
2,442 次查看

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 项奖励
14 回复数
JohnNichols
重要分销商 III
3,148 次查看

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 项奖励
Barbara_P_Intel
3,110 次查看

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


0 项奖励
Barbara_P_Intel
3,106 次查看

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 项奖励
Barbara_P_Intel
3,034 次查看

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

0 项奖励
Barbara_P_Intel
2,907 次查看

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


0 项奖励
Barbara_P_Intel
2,838 次查看

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

Give it a try!

 

0 项奖励
Harald1
新分销商 II
2,810 次查看

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 项奖励
jimdempseyatthecove
名誉分销商 III
2,807 次查看

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 项奖励
Steve_Lionel
名誉分销商 III
2,794 次查看

"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 项奖励
Barbara_P_Intel
2,729 次查看

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 项奖励
Harald1
新分销商 II
2,721 次查看

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
2,710 次查看

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 项奖励
Barbara_P_Intel
2,443 次查看

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 项奖励
Harald1
新分销商 II
2,430 次查看

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

Great, thanks!

This makes us all winners!

 

0 项奖励
回复