[Bug fortran/48746] [4.6/4.7 Regression] Matmul with allocate on assignment

2011-04-30 Thread tkoenig at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48746

--- Comment #7 from Thomas Koenig tkoenig at gcc dot gnu.org 2011-04-30 
11:12:29 UTC ---
Hi Paul,

the least I can do is to supply you with a more complete test case :-)

program main
  implicit none
  integer, parameter :: m=4, n=3, count=2
  double precision :: a(m, count), b(count, n), c(m,n)
  double precision, dimension(:,:), allocatable :: tmp

  data a /1.d0, -2.d0, 4.d0, -8.d0, 16.d0, -32.d0, 64.d0, -128.d0/
  data b /256.d0, -512.d0, 1024.d0, -2048.d0, 4096.d0, -8182.d0 /
  data c/  -7936.d0,  15872.d0, -31744.d0,  63488.d0, -31744.d0,  
   63488.d0,-126976.d0, 253952.d0,-126816.d0, 253632.d0, 
   -507264.d0,1014528.d0/

  tmp = matmul(a,b)
  if (size(tmp,1) /= 4 .or. size(tmp,2) /= 3) call abort
  if (any (tmp /= c)) call abort
end program main


[Bug fortran/48746] [4.6/4.7 Regression] Matmul with allocate on assignment

2011-04-30 Thread pault at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48746

--- Comment #8 from Paul Thomas pault at gcc dot gnu.org 2011-04-30 11:46:34 
UTC ---
Author: pault
Date: Sat Apr 30 11:46:31 2011
New Revision: 173213

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=173213
Log:
2011-04-30  Paul Thomas  pa...@gcc.gnu.org

PR fortran/48746
* trans-expr.c (fcncall_realloc_result): Set the bounds and the
offset so that the lbounds are one.
(gfc_trans_arrayfunc_assign): Add rank to arguments of above.

2011-04-30  Paul Thomas  pa...@gcc.gnu.org

PR fortran/48746
* gfortran.dg/realloc_on_assign_7.f03: Test bounds.

Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-expr.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.dg/realloc_on_assign_7.f03


[Bug fortran/48746] [4.6/4.7 Regression] Matmul with allocate on assignment

2011-04-30 Thread pault at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48746

--- Comment #9 from Paul Thomas pault at gcc dot gnu.org 2011-04-30 12:00:53 
UTC ---
Author: pault
Date: Sat Apr 30 12:00:50 2011
New Revision: 173214

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=173214
Log:
2011-04-30  Paul Thomas  pa...@gcc.gnu.org

PR fortran/48462
PR fortran/48746
* trans-expr.c ( arrayfunc_assign_needs_temporary): Need a temp
if automatic reallocation on assignement is active, the lhs is a
target and the rhs an intrinsic function.
(realloc_lhs_bounds_for_intrinsic_call): Rename as next.
(fcncall_realloc_result): Renamed version of above function.
Free the original descriptor data after the function call.Set the bounds
and the
offset so that the lbounds are one.
(gfc_trans_arrayfunc_assign): Call renamed function.

2011-04-30  Paul Thomas  pa...@gcc.gnu.org

PR fortran/48462
PR fortran/48746
* gfortran.dg/realloc_on_assign_7.f03: New test.


Added:
branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/realloc_on_assign_7.f03
Modified:
branches/gcc-4_6-branch/gcc/fortran/ChangeLog
branches/gcc-4_6-branch/gcc/fortran/trans-expr.c
branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


[Bug fortran/48746] [4.6/4.7 Regression] Matmul with allocate on assignment

2011-04-30 Thread pault at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48746

Paul Thomas pault at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED

--- Comment #10 from Paul Thomas pault at gcc dot gnu.org 2011-04-30 12:06:07 
UTC ---
Fixed on trunk at 4.6

Thanks for the report.

Paul


[Bug fortran/48746] [4.6/4.7 Regression] Matmul with allocate on assignment

2011-04-29 Thread pault at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48746

--- Comment #6 from Paul Thomas pault at gcc dot gnu.org 2011-04-29 20:26:59 
UTC ---
Author: pault
Date: Fri Apr 29 20:26:56 2011
New Revision: 173185

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=173185
Log:
2011-04-29  Paul Thomas  pa...@gcc.gnu.org

PR fortran/48462
* trans-expr.c (arrayfunc_assign_needs_temporary): Deal with
automatic reallocation when the lhs is a target.

PR fortran/48746
* trans-expr.c (fcncall_realloc_result): Make sure that the
result dtype field is set before the function call.

2011-04-29  Paul Thomas  pa...@gcc.gnu.org

PR fortran/48462
* gfortran.dg/realloc_on_assign_7.f03: Modify to test for lhs
being a target.

PR fortran/48746
* gfortran.dg/realloc_on_assign_7.f03: Add subroutine pr48746.

Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-expr.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.dg/realloc_on_assign_7.f03


[Bug fortran/48746] [4.6/4.7 Regression] Matmul with allocate on assignment

2011-04-28 Thread tkoenig at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48746

--- Comment #5 from Thomas Koenig tkoenig at gcc dot gnu.org 2011-04-28 
10:52:51 UTC ---
The problem is that matmul calls size0, which depends on correct
rank information in the dtype field.

Should be easy enough to fix by adding a default initializer
for the dtype field, if only anybody knew where to look...

Paul?


[Bug fortran/48746] [4.6/4.7 Regression] Matmul with allocate on assignment

2011-04-27 Thread burnus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48746

Tobias Burnus burnus at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||wrong-code
 CC||burnus at gcc dot gnu.org
   Target Milestone|--- |4.6.1
Summary|Matmul with allocate on |[4.6/4.7 Regression] Matmul
   |assignment  |with allocate on assignment

--- Comment #2 from Tobias Burnus burnus at gcc dot gnu.org 2011-04-27 
06:58:21 UTC ---
I think the PR is related to PR 48462, though the issue mentioned here is not
covered there.


[Bug fortran/48746] [4.6/4.7 Regression] Matmul with allocate on assignment

2011-04-27 Thread tkoenig at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48746

Thomas Koenig tkoenig at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2011.04.27 14:58:54
 Ever Confirmed|0   |1

--- Comment #3 from Thomas Koenig tkoenig at gcc dot gnu.org 2011-04-27 
14:58:54 UTC ---
(In reply to comment #1)
 Problem here is that the return array dtype field is uninitialized when
 lhs is (unallocated) allocatable. Due to this there are also similiar
 problems in other intrinsics such as reshape(), etc...

Interesting observation.  This works:

program main
  implicit none
  integer, parameter :: m=10, n=12, count=4
  double precision :: a(m, count), b(count, n), c(m, n)
  double precision, dimension(:,:), allocatable :: tmp

  call random_number(a)
  call random_number(b)
  allocate (tmp(3,3))
  deallocate(tmp)
  tmp = matmul(a,b)
end program main


[Bug fortran/48746] [4.6/4.7 Regression] Matmul with allocate on assignment

2011-04-27 Thread tkoenig at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48746

--- Comment #4 from Thomas Koenig tkoenig at gcc dot gnu.org 2011-04-27 
15:07:21 UTC ---
(In reply to comment #3)
 (In reply to comment #1)
  Problem here is that the return array dtype field is uninitialized when
  lhs is (unallocated) allocatable. Due to this there are also similiar
  problems in other intrinsics such as reshape(), etc...
 
 Interesting observation.  This works:

... well, for a given value of works.  tmp keeps its size of 3*3.