This works with g95 and ifort but gives a compiler error with gfortran: bash-3.1$ cat bug.F90 program bug implicit none real, dimension(3,3) :: matA,matB matA(1,:)=(/1., 2., 3./) matA(2,:)=(/4., 5., 6./) matA(3,:)=(/7., 8., 9./) matB=matmul(transpose(0.5*matA),matA) end program bug bash-3.1$ gfortran -v -Wall bug.F90 -o bug Driving: gfortran -v -Wall bug.F90 -o bug -lgfortranbegin -lgfortran -lm -shared-libgcc Reading specs from /usr/lib64/gcc/x86_64-slackware-linux/4.3.3/specs Target: x86_64-slackware-linux Configured with: ../gcc-4.3.3/configure --prefix=/usr --libdir=/usr/lib64 --enable-shared --enable-bootstrap --enable-languages=ada,c,c++,fortran,java,objc --enable-threads=posix --enable-checking=release --with-system-zlib --disable-libunwind-exceptions --enable-__cxa_atexit --enable-libssp --with-gnu-ld --verbose --disable-multilib --target=x86_64-slackware-linux --build=x86_64-slackware-linux --host=x86_64-slackware-linux Thread model: posix gcc version 4.3.3 (GCC) COLLECT_GCC_OPTIONS='-v' '-Wall' '-o' 'bug' '-shared-libgcc' '-mtune=generic' /usr/libexec/gcc/x86_64-slackware-linux/4.3.3/cc1 -E -lang-fortran -traditional-cpp -D_LANGUAGE_FORTRAN -quiet -v bug.F90 -mtune=generic -Wall -o /tmp/ccLe3BpA.f95 ignoring nonexistent directory "/usr/lib64/gcc/x86_64-slackware-linux/4.3.3/../../../../x86_64-slackware-linux/include" #include "..." search starts here: #include <...> search starts here: /usr/local/include /usr/lib64/gcc/x86_64-slackware-linux/4.3.3/include /usr/lib64/gcc/x86_64-slackware-linux/4.3.3/include-fixed /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-Wall' '-o' 'bug' '-shared-libgcc' '-mtune=generic' /usr/libexec/gcc/x86_64-slackware-linux/4.3.3/f951 /tmp/ccLe3BpA.f95 -ffree-form -quiet -dumpbase bug.F90 -mtune=generic -auxbase bug -Wall -version -fpreprocessed -fintrinsic-modules-path /usr/lib64/gcc/x86_64-slackware-linux/4.3.3/finclude -o /tmp/ccsYLGw0.s GNU F95 (GCC) version 4.3.3 (x86_64-slackware-linux) compiled by GNU C version 4.3.3, GMP version 4.2.4, MPFR version 2.3.1. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 bug.F90: In function 'bug': bug.F90:8: internal compiler error: in gfc_conv_array_transpose, at fortran/trans-array.c:734 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions.
ICE confirmed with test case on 4.5
853 gcc_assert (src_info->dimen == 2); (gdb) list 848 dest_ss = se->ss; 849 850 src_info = &src_ss->data.info; 851 dest_info = &dest_ss->data.info; 852 gcc_assert (dest_info->dimen == 2); 853 gcc_assert (src_info->dimen == 2); 854 855 /* Get a descriptor for EXPR. */ 856 gfc_init_se (&src_se, NULL); 857 gfc_conv_expr_descriptor (&src_se, expr, src_ss);
Not a regression.
This is what I would call a very fundamental bug, at the soul of what fortran is suppose to do. I am looking at it but think it would go better with a team effort here. Anyone have any thoughts about it?
I think we need to gfc_walk_op_expr before we try to gfc_conv_array_transpose
Removing the assert appears to fix this. Testing now.
Subject: Bug 41278 Author: jvdelisle Date: Thu Nov 26 19:05:37 2009 New Revision: 154680 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154680 Log: 2009-11-26 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/41278 * trans-array.c (gfc_conv_array_transpose): Delete unnecessary assert. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-array.c
Subject: Bug 41278 Author: jvdelisle Date: Thu Nov 26 19:10:29 2009 New Revision: 154681 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154681 Log: 2009-11-26 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/41278 * gfortran.dg/array_function_5.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/array_function_5.f90 Modified: trunk/gcc/testsuite/ChangeLog
The following assert is wrong: gcc_assert (src_info->dimen == 2); (and has been removed in the comment patch of comment 7). I only want to link to an email which gives the reason why. http://gcc.gnu.org/ml/fortran/2009-11/msg00212.html
Just a note of appreciation to Chris for reporting this bug and providing a simple and extremely useful test case. When I get a moment, I will add Chris to the test case as recognition. Shall we backport this fix to 4.4?
(In reply to comment #10) > Just a note of appreciation to Chris for reporting this bug and providing a > simple and extremely useful test case. When I get a moment, I will add Chris > to the test case as recognition. > > Shall we backport this fix to 4.4? I would say one should: The fix is extremely simple and having TRANSPOSE is not uncommon in Fortran. (Having TRANSPOSE(<scalar> <operator> <array>) is less common, though.)
Subject: Bug 41278 Author: jvdelisle Date: Tue Dec 1 04:36:30 2009 New Revision: 154863 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154863 Log: 2009-11-30 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/41278 Backport from mainline. * trans-array.c (gfc_conv_array_transpose): Delete unnecessary assert. Modified: branches/gcc-4_4-branch/gcc/fortran/ChangeLog branches/gcc-4_4-branch/gcc/fortran/trans-array.c
Subject: Bug 41278 Author: jvdelisle Date: Tue Dec 1 04:40:14 2009 New Revision: 154864 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154864 Log: 2009-11-30 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/41278 * gfortran.dg/array_function_5.f90: New test. Added: branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/array_function_5.f90 Modified: branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
Fixed on Trunk and 4.4