Bug 41278 - internal compiler error related to matmul and transpose
internal compiler error related to matmul and transpose
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: fortran
4.3.3
: P3 normal
: ---
Assigned To: Jerry DeLisle
: ice-on-valid-code
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2009-09-05 14:38 UTC by chris
Modified: 2009-12-01 04:41 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.1.2 4.3.1 4.4.0 4.5.0
Last reconfirmed: 2009-09-05 15:19:09


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description chris 2009-09-05 14:38:10 UTC
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.
Comment 1 Jerry DeLisle 2009-09-05 14:54:18 UTC
ICE confirmed with test case on 4.5
Comment 2 Joost VandeVondele 2009-09-05 15:34:14 UTC
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);
Comment 3 Thomas Koenig 2009-09-08 16:21:52 UTC
Not a regression.
Comment 4 Jerry DeLisle 2009-11-26 13:02:14 UTC
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?
Comment 5 Jerry DeLisle 2009-11-26 14:35:00 UTC
I think we need to gfc_walk_op_expr before we try to gfc_conv_array_transpose

Comment 6 Jerry DeLisle 2009-11-26 17:50:17 UTC
Removing the assert appears to fix this.  Testing now.
Comment 7 Jerry DeLisle 2009-11-26 19:05:57 UTC
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

Comment 8 Jerry DeLisle 2009-11-26 19:10:51 UTC
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

Comment 9 Tobias Burnus 2009-11-26 21:46:41 UTC
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
Comment 10 Jerry DeLisle 2009-11-26 22:11:14 UTC
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?
Comment 11 Tobias Burnus 2009-11-27 08:34:24 UTC
(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.)
Comment 12 Jerry DeLisle 2009-12-01 04:36:45 UTC
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

Comment 13 Jerry DeLisle 2009-12-01 04:40:30 UTC
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

Comment 14 Jerry DeLisle 2009-12-01 04:41:10 UTC
Fixed on Trunk and 4.4