public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/21108] New: reshape with order causes memory corruption
@ 2005-04-19 20:09 tkoenig at gcc dot gnu dot org
  2005-04-22 13:22 ` [Bug libfortran/21108] " tobi at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2005-04-19 20:09 UTC (permalink / raw)
  To: gcc-bugs

... or so it seems.

This doesn't work:

$ cat reshape-2.f90
program resh
  real, dimension (0:1,0:2) :: a,c
  real, dimension (12) :: b
  b = (/(i,i=1,12)/)
  a = reshape(b(1:12:2),shape(a),order=(/2,1/))
  print '(6F8.3)',a
  c = reshape(b(1:12:2),shape(a),order=(/2,1/))
  print '(6F8.3)',c
end
$ gfortran reshape-2.f90
$ ./a.out
   0.000   0.000   0.000   2.029   2.027   2.025
  -2.000   2.022   0.000   2.166   0.000   0.000

This works:
$ cat reshape-2.f90
program resh
  real, dimension (0:1,0:2) :: a,c
  real, dimension (12) :: b
  b = (/(i,i=1,12)/)
  a = reshape(b(1:12:2),shape(a),order=(/2,1/))
  print '(6F8.3)',a
  c = reshape(b(1:12:2),shape(a),order=(/2,1/))
  print '(6F8.3)',c
end
$ gfortran reshape-2.f90
$ ./a.out
   0.000   0.000   0.000   2.029   2.027   2.025
  -2.000   2.022   0.000   2.166   0.000   0.000
$ gfortran -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.1/configure --enable-languages=c,f95 --prefix=/home/ig25
Thread model: posix
gcc version 4.1.0 20050419 (experimental)

Reshape is trickier than I thought, apparently.

-- 
           Summary: reshape with order causes memory corruption
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tkoenig at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21108


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libfortran/21108] reshape with order causes memory corruption
  2005-04-19 20:09 [Bug libfortran/21108] New: reshape with order causes memory corruption tkoenig at gcc dot gnu dot org
@ 2005-04-22 13:22 ` tobi at gcc dot gnu dot org
  2005-04-22 20:03 ` cvs-commit at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-04-22 13:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2005-04-22 13:21 -------
I think you copy/pasted the wrong "working" testcase.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tobi at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21108


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libfortran/21108] reshape with order causes memory corruption
  2005-04-19 20:09 [Bug libfortran/21108] New: reshape with order causes memory corruption tkoenig at gcc dot gnu dot org
  2005-04-22 13:22 ` [Bug libfortran/21108] " tobi at gcc dot gnu dot org
@ 2005-04-22 20:03 ` cvs-commit at gcc dot gnu dot org
  2005-04-23 18:10 ` [Bug libfortran/21108] [4.0 only] reshape with order causes random results tkoenig at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-04-22 20:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-04-22 20:02 -------
Subject: Bug 21108

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tkoenig@gcc.gnu.org	2005-04-22 20:02:44

Modified files:
	gcc/testsuite  : ChangeLog 
	libgfortran    : ChangeLog 
	libgfortran/generated: reshape_i4.c reshape_i8.c 
	libgfortran/intrinsics: reshape_generic.c 
	libgfortran/m4 : reshape.m4 
Added files:
	gcc/testsuite/gfortran.dg: nested_reshape.f90 reshape-alloc.f90 
	                           reshape.f90 

Log message:
	05-04-22  Thomas Koenig  <Thomas.Koenig@online.de>
	
	PR libfortran/20074
	PR libfortran/20436
	PR libfortran/21108
	* gfortran.dg/nested_reshape.f90: new test
	* gfortran.dg/reshape-alloc.f90: new test
	* gfortran.dg/reshape.f90: new test
	
	2005-04-22  Thomas Koenig  <Thomas.Koenig@online.de>
	
	PR libfortran/20074
	PR libfortran/20436
	PR libfortran/21108
	* m4/reshape.m4 (reshape_`'rtype_kind):  rs, rex:  New
	variables, to be used in calculation of return array sizes.
	Populate return array descriptor if ret->data is NULL.
	Fix condition for early return (it used to test something
	undefined if order was used).
	Remove duplicate check wether pad is used.
	* intrinsics/reshape_generic.c (reshape_generic): Likewise.
	Fix a few places where the wrong variables were set.
	* generated/reshape_i4.c: Regenerated.
	* generated/reshape_i8.c: Regenerated.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/nested_reshape.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/reshape-alloc.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/reshape.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5383&r2=1.5384
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&r1=1.198&r2=1.199
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/generated/reshape_i4.c.diff?cvsroot=gcc&r1=1.6&r2=1.7
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/generated/reshape_i8.c.diff?cvsroot=gcc&r1=1.6&r2=1.7
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/intrinsics/reshape_generic.c.diff?cvsroot=gcc&r1=1.7&r2=1.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/m4/reshape.m4.diff?cvsroot=gcc&r1=1.7&r2=1.8



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21108


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libfortran/21108] [4.0 only] reshape with order causes random results
  2005-04-19 20:09 [Bug libfortran/21108] New: reshape with order causes memory corruption tkoenig at gcc dot gnu dot org
  2005-04-22 13:22 ` [Bug libfortran/21108] " tobi at gcc dot gnu dot org
  2005-04-22 20:03 ` cvs-commit at gcc dot gnu dot org
@ 2005-04-23 18:10 ` tkoenig at gcc dot gnu dot org
  2005-04-29 11:02 ` fxcoudert at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2005-04-23 18:10 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tkoenig at gcc dot gnu dot org  2005-04-23 18:09 -------
> I think you copy/pasted the wrong "working" testcase.

Yes, I did :-(

Here is a corrected version.

$ gfortran reshape-0.f90
$ ./a.out
Aborted
$ cat reshape-0.f90
! { dg-do run }
! This tests a few reshape PRs.
program resh
  implicit none
  real, dimension (2,3) :: a,c
  real, dimension (12) :: b
  integer :: i

  ! PR 21108:  This used to give undefined results.
  b = (/(i,i=1,12)/)
  a = reshape(b(1:12:2),shape(a),order=(/2,1/))
  c = reshape(b(1:12:2),shape(a),order=(/2,1/))
  if (any (a /= c)) call abort

end

$ gfortran -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.0/configure --prefix=/home/ig25
--enable-languages=c,f95 --enable-checking
Thread model: posix
gcc version 4.0.1 20050423 (prerelease)

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.0.1
      Known to work|                            |4.1.0
            Summary|reshape with order causes   |[4.0 only] reshape with
                   |memory corruption           |order causes random results
   Target Milestone|---                         |4.0.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21108


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libfortran/21108] [4.0 only] reshape with order causes random results
  2005-04-19 20:09 [Bug libfortran/21108] New: reshape with order causes memory corruption tkoenig at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2005-04-23 18:10 ` [Bug libfortran/21108] [4.0 only] reshape with order causes random results tkoenig at gcc dot gnu dot org
@ 2005-04-29 11:02 ` fxcoudert at gcc dot gnu dot org
  2005-05-21 19:57 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2005-04-29 11:02 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-04-29 11:02:27
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21108


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libfortran/21108] [4.0 only] reshape with order causes random results
  2005-04-19 20:09 [Bug libfortran/21108] New: reshape with order causes memory corruption tkoenig at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2005-04-29 11:02 ` fxcoudert at gcc dot gnu dot org
@ 2005-05-21 19:57 ` cvs-commit at gcc dot gnu dot org
  2005-05-21 20:30 ` tkoenig at gcc dot gnu dot org
  2005-07-30 22:41 ` cvs-commit at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-05-21 19:57 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-05-21 19:57 -------
Subject: Bug 21108

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	tkoenig@gcc.gnu.org	2005-05-21 19:56:44

Modified files:
	libgfortran/generated: reshape_c4.c reshape_c8.c reshape_i4.c 
	                       reshape_i8.c 
	libgfortran/intrinsics: reshape_generic.c 
	libgfortran/m4 : reshape.m4 
	libgfortran    : ChangeLog 
	gcc/testsuite  : ChangeLog 

Log message:
	005-05-21  Thomas Koenig  <Thomas.Koenig@online.de>
	
	PR libfortran/20074
	PR libfortran/20436
	PR libfortran/21108
	* m4/reshape.m4 (reshape_`'rtype_kind):  rs, rex:  New
	variables, to be used in calculation of return array sizes.
	Populate return array descriptor if ret->data is NULL.
	Fix condition for early return (it used to test something
	undefined if order was used).
	Remove duplicate check wether pad is used.
	* intrinsics/reshape_generic.c (reshape_generic): Likewise.
	Fix a few places where the wrong variables were set.
	* generated/reshape_i4.c: Regenerated.
	* generated/reshape_i8.c: Regenerated.
	
	2005-05-21  Thomas Koenig  <Thomas.Koenig@online.de>
	
	PR libfortran/20074
	PR libfortran/20436
	PR libfortran/21108
	* gfortran.dg/nested_reshape.f90: new test
	* gfortran.dg/reshape-alloc.f90: new test
	* gfortran.dg/reshape.f90: new test

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/generated/reshape_c4.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1.2.1&r2=1.1.2.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/generated/reshape_c8.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1.2.1&r2=1.1.2.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/generated/reshape_i4.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5&r2=1.5.12.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/generated/reshape_i8.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5&r2=1.5.12.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/intrinsics/reshape_generic.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.6&r2=1.6.12.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/m4/reshape.m4.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.6.12.1&r2=1.6.12.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.163.2.35&r2=1.163.2.36
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.192&r2=1.5084.2.193



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21108


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libfortran/21108] [4.0 only] reshape with order causes random results
  2005-04-19 20:09 [Bug libfortran/21108] New: reshape with order causes memory corruption tkoenig at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2005-05-21 19:57 ` cvs-commit at gcc dot gnu dot org
@ 2005-05-21 20:30 ` tkoenig at gcc dot gnu dot org
  2005-07-30 22:41 ` cvs-commit at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2005-05-21 20:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tkoenig at gcc dot gnu dot org  2005-05-21 20:30 -------
Fixed in 4.0.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21108


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libfortran/21108] [4.0 only] reshape with order causes random results
  2005-04-19 20:09 [Bug libfortran/21108] New: reshape with order causes memory corruption tkoenig at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2005-05-21 20:30 ` tkoenig at gcc dot gnu dot org
@ 2005-07-30 22:41 ` cvs-commit at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-07-30 22:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-07-30 22:29 -------
Subject: Bug 21108

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	tkoenig@gcc.gnu.org	2005-07-30 22:29:25

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: nested_reshape.f90 reshape-alloc.f90 
	                           reshape.f90 

Log message:
	2005-07-30  Thomas Koenig  <Thomas.Koenig@online.de>
	
	Backport from mainline:
	PR libfortran/20074
	PR libfortran/20436
	PR libfortran/21108
	* gfortran.dg/nested_reshape.f90:  Actually commit.
	* gfortran.dg/reshape-alloc.f90:  Actually commit.
	* gfortran.dg/reshape.f90:  Actually commit.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.311&r2=1.5084.2.312
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/nested_reshape.f90.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.14.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/reshape-alloc.f90.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.14.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/reshape.f90.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.14.1



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21108


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-07-30 22:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-19 20:09 [Bug libfortran/21108] New: reshape with order causes memory corruption tkoenig at gcc dot gnu dot org
2005-04-22 13:22 ` [Bug libfortran/21108] " tobi at gcc dot gnu dot org
2005-04-22 20:03 ` cvs-commit at gcc dot gnu dot org
2005-04-23 18:10 ` [Bug libfortran/21108] [4.0 only] reshape with order causes random results tkoenig at gcc dot gnu dot org
2005-04-29 11:02 ` fxcoudert at gcc dot gnu dot org
2005-05-21 19:57 ` cvs-commit at gcc dot gnu dot org
2005-05-21 20:30 ` tkoenig at gcc dot gnu dot org
2005-07-30 22:41 ` cvs-commit at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).