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

What is the nature of this compiler bug in 10.1.008?

Edwin_B_
Beginner
1,627 Views
This program produces the wrong answers using 10.1.008 when compiled as shown. It works with 11.1.064 or with 10.1.008 if you compile -O0. I am just wondering if anyone knows what was the root cause of this bug? Thanks.

% ifort -o bob bob.f90; ./bob
1.000000 -2.000000 3.000000 -4.000000 5.000000
-6.000000

All the numbers should be positive.

program bob
real, dimension(6) :: ta
ta(1)=-1
ta(2)=-2
ta(3)=-3
ta(4)=-4
ta(5)=-5
ta(6)=-6
ta(6)=6
ta(5)=5
ta(4)=4
ta(3)=3
ta(2)=2
ta(1)=1
write(*,*) ta(1), ta(2), ta(3), ta(4), ta(5), ta(6)
end program bob

0 Kudos
5 Replies
mecej4
Honored Contributor III
1,627 Views
I cannot reproduce the error with the 10.1.018 compiler on IA-64, which is the closest version number that I have access to.
0 Kudos
Edwin_B_
Beginner
1,627 Views
Thanks for checking. Perhaps it only appears on x86_64. I am able to reproduce the problem with 10.1.021 (on a different host),as shown below,but both hosts are Intel Xeon processors.

user@fwhpctest
:~> /appserv/intel/fce/10.1.021/bin/ifort -o bob bob.f90
user@fwhpctest:~> ./bob
1.000000 2.000000 -3.000000 4.000000 -5.000000
6.000000
user@fwhpctest:~> uname -a
Linux fwhpctest 2.6.16.60-0.42.10-smp #1 SMP Tue Apr 27 05:11:27 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux
0 Kudos
Steven_L_Intel1
Employee
1,627 Views
Without going back into the 10.1 sources, reproducing the bug, and seeing what needed to be changed, your question is not likely to be answerable. I could make some guesses, but they'd probably be wrong. Is this important?
0 Kudos
Edwin_B_
Beginner
1,627 Views
No, not important, just asking to see if the reason was obvious. If you can guess without taking too much of your time, yes I'd appreciate getting a sense of what the problem could have been.

A 'regular user' caught this problem and made a big stink, so I thought I'd try to do some damage control by offering a reasonable explanation, followed by "upgrade to 11.x and it will fix the problem".
0 Kudos
Kevin_D_Intel
Employee
1,627 Views

The root cause is a defect in the middle-end optimizer (at O1 and higher which is why O0 works) that incorrectly reorders the assignments.

Depending on the 10.1 version used the re-ordering may differ slightly (note that your 10.1.008 and 10.1.021 results are both incorrect but different). The line numbers below are the original line numbers as reordered when using 10.1.008.

1program bob
2 real, dimension(6) :: ta
3 ta(1)=-1
14ta(1)=1
13ta(2)=2
4 ta(2)=-2
5 ta(3)=-3
12 ta(3)=3
11 ta(4)=4
6 ta(4)=-4
7 ta(5)=-5
10 ta(5)=5
9 ta(6)=6
8 ta(6)=-6
15 write(*,*) ta(1), ta(2), ta(3), ta(4), ta(5), ta(6)
16 end program bob


Note the incorrect placement of lines 13, 11, and 8 leading to negative values. Which produces the following incorrect results.

$ ifort -V -o bob bob.f90;./bob
Intel Fortran Compiler for applications running on Intel 64, Version 10.1 Build 20070913 Package ID: l_fc_p_10.1.008
Copyright (C) 1985-2007 Intel Corporation. All rights reserved.
Intel Fortran 10.0-2024
GNU ld version 2.17.50.0.6-5.el5 20061020

1.000000 -2.000000 3.000000 -4.000000 5.000000
-6.000000

From testing many compilers it appears this was fixed in the initial 11.1 Release, Version 11.1 Build 20090630 (Linux:l_cprof_p_11.1.046)

0 Kudos
Reply