#34535 closed defect (fixed)
gcc45 @4.5.3_4 gfortran gives wrong results for log and exp functions on OSX lion
Reported by: | SiggyF | Owned by: | mww@… |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.1.1 |
Keywords: | Cc: | tenomoto (Takeshi Enomoto) | |
Port: | gcc45 |
Description
The gfortran compiler generates programs that give incorrect results on OSX lion. I have tested the following program with gfortran-mp-4.5 and gfortran-mp-4.7.
program test_exp write(*,*) exp(1.0), log(2.7182818284590451) end program test_exp
This should result in the following output: 2.71... 1.0...
However on OSX Lion with gfortran it results in: 2.7699862 1.3489696
I have tested it with:
gcc45 @4.5.3_4
and
gcc47 @4.7.0_3
See also http://stackoverflow.com/questions/10673701/can-i-call-the-fortran-log-function-with-a-number for several related test cases.
Attachments (1)
Change History (9)
Changed 13 years ago by SiggyF
comment:1 follow-up: 2 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)
Owner: | changed from macports-tickets@… to mww@… |
---|---|
Port: | gcc45 added |
comment:2 Changed 13 years ago by SiggyF
I rebuild the gfortran47 compiler using port -s gcc47, but it also gives the wrong results.
comment:4 Changed 12 years ago by SiggyF
It seems to be related to a broken mpfr.
http://llvm.org/bugs/show_bug.cgi?id=11111
When I do:
port build mpfr
and then run
make check
in the build folder I get errors like this:
[tversion] MPFR tuning parameters from src/x86_64/core2/mparam.h PASS: tversion PASS: tinternals PASS: tinits PASS: tisqrt PASS: tsgn PASS: tcheck PASS: tisnan PASS: texceptions PASS: tset_exp PASS: tset PASS: mpf_compat PASS: mpfr_compat Error for mpfr_ui_pow(a, b, a) for b=1764214285 a=1.10010010000111111011010101001e1 expected1.00011111011011011011010011100e92, got 1.10000100011010001011111101100e87 FAIL: reuse PASS: tabs results differ for x=1.11001100001000101110010110101100001010000000000e-27 prec=55 rnd_mode=MPFR_RNDN got 1.100100011101111000010011110101010001100111011011001010 expected 1.100100011101111000010011111100011011011011001111000100 approx 0.11001000111011110000100111111000110110110110011110000111111001011E1 FAIL: tacos Error: mpfr_acosh (1) FAIL: tacosh PASS: tadd PASS: tadd1sp PASS: tadd_d PASS: tadd_ui results differ for x=1.111111000111011100011011111101110100101101000001011110101000010110001000111000011010101001100000100111011100111100010111000000110000010111010010001111110101001101001101101101111110101110100000110e-1 u=1.100000111110010000111001000100100000011110010110000111001111000101010100001011010111100011011011011001100100100100000111111100101101110001000010110111100111001111101001010101111010111110010011110e-2 prec=222 rnd_mode=MPFR_RNDU got 1.01001100010110111001000011110110001011111100000110100110111010010000010100101111111001111001110101010001011100010110000001100000101100011111011110110111111111000100000011000000010111110010010110010100101111000001011101100e-1 expected 1.01001100010110111001000011110110001011111100000110100110111010010000010100101111111001111001110101010001011100010110000001100000101100011111011110110111111111000100000011000000010111110010010110010101110011110101010110001e-1 approx 0.1010011000101101110010000111101100010111111000001101001101110100100000101001011111110011110011101010100010111000101100000011000001011000111110111101101111111110001000000110000000101111100100101100101011100111101010101100001110001000E0 FAIL: tagm
This appears to be related to #33361.
comment:5 Changed 12 years ago by SiggyF
I managed to solve this by changing the compiler in gmp from clang to macports-gcc-4.5. After that the test cases in mpfr all passed and also my fortran test.
comment:6 Changed 12 years ago by tenomoto (Takeshi Enomoto)
Has the update of gmp in r94119 fixed the problem? I didn't encounter the problem (maybe because I 'm using Xcode 4.3), I can't tell. BTW, the changes in r94119 is to remove the use of clang when llvm-gcc-4.2 is specified. The default is clang on Lion so I'm not sure if the changes fixed the gfortran problem.
comment:7 Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)
Resolution: | → fixed |
---|---|
Status: | new → closed |
r94119 should have fixed it. Assuming it did, since there was no response to the above question.
comment:8 Changed 12 years ago by SiggyF
Thanks that fixed it. The output of my test program is now:
2.7182817 0.99999994
test program to check for problem with log/exp