Broken arguments access Starting February 13th, gfrotran fails on the following test case on ia32/ia64/x86_64 platforms with all kinds of optimizations: -O0, -O1, -O2 etc. The issue is critical because it affects SPEC cpu2k tests wupwise and galgel on all platforms.
$ cat foo.f program foo character*1 a1, a2, b a1='A' a2='A' b='B' x = LSAME(a1,a2) if ( x.eq.1 ) then write(*,*) 'passsed' else write(*,*) 'failed' endif end logical function LSAME( CA, CB ) character CA, CB integer INTA, INTB INTA = ICHAR( CA ) INTB = ICHAR( CB ) write(*,*) INTA, INTB LSAME = INTA.EQ.INTB end The reason of failure is the broken argument access for the function. Here is the ia32 Linux code obtained with -O0 optimization. .type lsame_, @function lsame_: pushl %ebp movl %esp, %ebp subl $16, %esp movl 8(%ebp), %eax movb -1(%eax), %al <-- Wrong. Must be "movb (%eax), %al" movzbl %al, %eax movl %eax, -8(%ebp) movl 12(%ebp), %eax movb -1(%eax), %al <-- Wrong. Must be "movb (%eax), %al" movzbl %al, %eax This issue has been discussed here http://gcc.gnu.org/ml/gcc/2005- 02/msg00685.html but not resolved yet and bug search gave me nothing. It appears that breakage introduced by revision 2.110 (and later 2.112) of gcc/gimplify.c. The exact place is: $ cvs diff -r 2.111 -r 2.112 gcc/gimplify.c 3797a3799,3803 > case INDIRECT_REF: > *expr_p = fold_indirect_ref (*expr_p); > if (*expr_p != save_expr) > break; > /* else fall through. */ 3800d3805 < case INDIRECT_REF: -- Summary: Broken arguments access Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: grigory dot zagorodnev at intel dot com CC: gcc-bugs at gcc dot gnu dot org GCC host triplet: i686-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20030