If you have code doing something like: INTEGER*2 RES1, RES2, RES3 REAL*4 GPA RES1 = GPA * X'6B5' RES2 = GPA * (X'6B5') WRITE(*,*) RES1 WRITE(*,*) RES2 these are the results you get with different compilation options: %>g77 -fugly-logint -ftypeless-boz test.f %>./a.out 0 9271 %>g77 -fugly-logint test.f %>./a.out 9271 9271 %>g77 -ftypeless-boz test.f test.f: In program `main': test.f:10: RES1 = GPA * X'6B5' 1 2 Arithmetic operator at (1) must operate on two subexpressions of arithmetic type, but the subexpression at (2) is not of arithmetic type %>g77 test.f %>./a.out 9271 9271 %>
On the mainline (20031029 on powerpc-apple-darwin7.0): [zhivago2:~/src/gccPRs] pinskia% ~/fsf-clean-nocheck/bin/g77 -fugly-logint -ftypeless-boz pr13213.f [zhivago2:~/src/gccPRs] pinskia% ./a.out 0 0 [zhivago2:~/src/gccPRs] pinskia% ~/fsf-clean-nocheck/bin/g77 -fugly-logint pr13213.f [zhivago2:~/src/gccPRs] pinskia% ./a.out 0 0 [zhivago2:~/src/gccPRs] pinskia% ~/fsf-clean-nocheck/bin/g77 -ftypeless-boz pr13213.f pr13213.f: In program `MAIN__': pr13213.f:4: RES1 = GPA * X'6B5' 1 2 Arithmetic operator at (1) must operate on two subexpressions of arithmetic type, but the subexpression at (2) is not of arithmetic type [zhivago2:~/src/gccPRs] pinskia% ~/fsf-clean-nocheck/bin/g77 pr13213.f [zhivago2:~/src/gccPRs] pinskia% ./a.out 0 0 What version are you using or has something changed since then?
Same problem on version 2.96
Some how related to bug 12633 and 6491.
I don't know if it's necessarily related to those bugs... they seem to be an order of operations problem. The problem I presented here is more of a typecasting problem. Also, I don't have a problem if I *only* use ugly-logint (like the other two bugs)... it's only if I use ugly-logint *with* typeless-boz. In my source line: RES1 = GPA * X'6B5' GPA is a REAL, so what I believe is happening is that X'6B5' is being interpreted as the hex representation of a real (not sure), but anyway, it's evaluating to zero. If, however, you use the other way: RES2 = GPA * (X'6B5') then X'6B5' evaluates to its decimal equivalent: 1717 I found that the same problem occurs with .le., .eq., etc. If you compile the following lines with BOTH ugly-logint and typeless-boz: GPA = 5.4 IF (GPA.LE.X'B0') IF (GPA.LE.(X'B0')) the first line evaluates to FALSE while the second line evaluates to TRUE. The same thing happens if you use .EQ., .GT., etc.
What is the correct answer?
Okay I am just going to say this is fixed, the patch which fixed this was also applied to the 3.3 branch, so this fixed for 3.3.3 and 3.4.
There is no reference of the patch, would you please provide a link Andrew?
Patch for mainline: <http://gcc.gnu.org/ml/gcc-patches/2003-11/msg01961.html>. Patch that was reverted for 3.3.3: <http://gcc.gnu.org/ml/gcc-patches/2003-12/ msg00599.html>.