- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following example code gives incorrect results with ifx version 2022.1.0
PROGRAM ifx_equiv
IMPLICIT NONE
REAL :: a(5) = [1.0, 2.0, 3.0, 4.0, 5.0]
REAL :: b(5) = [6.0, 7.0, 8.0, 9.0,10.0]
REAL :: c(10)
EQUIVALENCE (a(1), c(1))
EQUIVALENCE (b(1), c(6))
! DATA a /1.0, 2.0, 3.0, 4.0, 5.0/
! DATA b /6.0, 7.0, 8.0, 9.0, 10.0/
! a = [1.0, 2.0, 3.0, 4.0, 5.0]
! b = [6.0, 7.0, 8.0, 9.0,10.0]
WRITE(*,'("a = ", 5F5.1)') a
WRITE(*,'("b = ", 5F5.1)') b
WRITE(*,'("c = ", 10F5.1)') c
END PROGRAM ifx_equiv
The (incorrect) output when compiled with ifx is:
a = 1.0 2.0 3.0 4.0 5.0
b = 0.0 0.0 0.0 0.0 0.0
c = 1.0 2.0 3.0 4.0 5.0 0.0 0.0 0.0 0.0 0.0
The (correct) output when compiled with ifort or gfortran is:
a = 1.0 2.0 3.0 4.0 5.0
b = 6.0 7.0 8.0 9.0 10.0
c = 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0
If you replace the default initialization of the arrays with the commented out DATA statements the same error occurs. However, if you explicitly initialize the arrays, as in the commented out lines 15 and 16, then the error does not occur.
This looks to me like an ifx compiler bug.
I realize that EQUIVALENCE is an obsolete language feature which can be unsafe and should be avoided. This minimum example is based on a legacy routine in a production code which was found to give incorrect results with the ifx compiler as a consequence of this error.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Still fails in ifx 2022.2.0.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We'll get a bug report on this. Thanks for catching it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This was fixed in future release.
ifort equiv.f90 -o eq
$ ./eq
a = 1.0 2.0 3.0 4.0 5.0
b = 6.0 7.0 8.0 9.0 10.0
c = 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0
$ ifx equiv.f90 -o eq
$ ./eq
a = 1.0 2.0 3.0 4.0 5.0
b = 6.0 7.0 8.0 9.0 10.0
c = 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0
$

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page