public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/29785]  New: Fortran 2003: POINTER Rank Remapping
@ 2006-11-09 18:48 burnus at gcc dot gnu dot org
  2006-11-09 18:48 ` [Bug fortran/29785] " burnus at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2006-11-09 18:48 UTC (permalink / raw)
  To: gcc-bugs

POINTER Rank Remapping

(From http://www.fortran.bcs.org/forum2002/f2000dme.htm)
Motivation: ability to have pointers to diagonals of matrices.

  REAL,ALLOCATABLE,TARGET :: base_array(:)
  REAL,POINTER :: matrix(:,:)
  REAL,POINTER :: diagonal(:)
  ...
  ALLOCATE(base_array(n*n))
  matrix(1:n,1:n) => base_array ! rank remapping
  diagonal => base_array(::n+1)

Notes:

* The base array must be rank one, to ensure that the remapping is a simple
linear transformation.
* Both lower bound and upper bound must be specified for each dimension.

Fortran 2003 standard, see "7.4.2.1 Data pointer assignment":
"R735 pointer-assignment-stmt
   is data-pointer-object [ (bounds-spec-list) ] => data-target
   or data-pointer-object (bounds-remapping-list ) => data-target
   or proc-pointer-object => proc-target

C718 (R735) If bounds-spec-list is specified, the number of bounds-specs shall 
            equal the rank of data pointer-object.
C719 (R735) If bounds-remapping-list is specified, the number of 
            bounds-remappings shall equal the rank of data-pointer-object.
C720 (R735) If bounds-remapping-list is specified, data-target shall have rank 
            one; otherwise, the ranks of data-pointer-object and data-target
            shall be the same."

and "7.4.2.1 Data pointer assignment":
"If bounds-remapping-list is specified, data-target shall not be a
disassociated or undefined pointer, and the size of data-target shall not be
less than the size of data-pointer-object. The elements of the target of
data-pointer-object, in array element order (6.2.2.2), are the first
SIZE(data-pointer-object) elements of data-target."


-- 
           Summary: Fortran 2003: POINTER Rank Remapping
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org
OtherBugsDependingO 20585
             nThis:


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


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

* [Bug fortran/29785] Fortran 2003: POINTER Rank Remapping
  2006-11-09 18:48 [Bug fortran/29785] New: Fortran 2003: POINTER Rank Remapping burnus at gcc dot gnu dot org
@ 2006-11-09 18:48 ` burnus at gcc dot gnu dot org
  2007-04-12  8:19 ` burnus at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2006-11-09 18:48 UTC (permalink / raw)
  To: gcc-bugs



-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-11-09 18:48:08
               date|                            |


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


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

* [Bug fortran/29785] Fortran 2003: POINTER Rank Remapping
  2006-11-09 18:48 [Bug fortran/29785] New: Fortran 2003: POINTER Rank Remapping burnus at gcc dot gnu dot org
  2006-11-09 18:48 ` [Bug fortran/29785] " burnus at gcc dot gnu dot org
@ 2007-04-12  8:19 ` burnus at gcc dot gnu dot org
  2008-07-03 16:10 ` burnus at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-04-12  8:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2007-04-12 09:19 -------
Cf. http://gcc.gnu.org/ml/fortran/2007-04/msg00120.html


-- 


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


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

* [Bug fortran/29785] Fortran 2003: POINTER Rank Remapping
  2006-11-09 18:48 [Bug fortran/29785] New: Fortran 2003: POINTER Rank Remapping burnus at gcc dot gnu dot org
  2006-11-09 18:48 ` [Bug fortran/29785] " burnus at gcc dot gnu dot org
  2007-04-12  8:19 ` burnus at gcc dot gnu dot org
@ 2008-07-03 16:10 ` burnus at gcc dot gnu dot org
  2009-08-07  7:35 ` jv244 at cam dot ac dot uk
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-07-03 16:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2008-07-03 16:09 -------
In Fortran 2008 the rank-one constraint is gone:

"C720 If bounds-remapping-list is not specified, the ranks of
data-pointer-object and data-target shall be the same."


-- 


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


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

* [Bug fortran/29785] Fortran 2003: POINTER Rank Remapping
  2006-11-09 18:48 [Bug fortran/29785] New: Fortran 2003: POINTER Rank Remapping burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2008-07-03 16:10 ` burnus at gcc dot gnu dot org
@ 2009-08-07  7:35 ` jv244 at cam dot ac dot uk
  2010-07-21  9:03 ` burnus at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jv244 at cam dot ac dot uk @ 2009-08-07  7:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jv244 at cam dot ac dot uk  2009-08-07 07:35 -------
still missing 4.5.0, this seems a particularly useful F03 feature ;-) 

For an expert, should be 'easy' to add (ignoring the F2008 variant) ?


-- 

jv244 at cam dot ac dot uk changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2006-11-09 18:48:08         |2009-08-07 07:35:07
               date|                            |


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


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

* [Bug fortran/29785] Fortran 2003: POINTER Rank Remapping
  2006-11-09 18:48 [Bug fortran/29785] New: Fortran 2003: POINTER Rank Remapping burnus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2009-08-07  7:35 ` jv244 at cam dot ac dot uk
@ 2010-07-21  9:03 ` burnus at gcc dot gnu dot org
  2010-07-21  9:06 ` domob at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-07-21  9:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from burnus at gcc dot gnu dot org  2010-07-21 09:03 -------
Fortran 2008 has the following, which I missed to quote:

"If bounds-remapping-list is specified, the pointer target shall be simply
contiguous (6.5.4) or of rank one. It shall not be a disassociated or undefined
pointer, and the size of the pointer target shall not be less than the size of
the pointer object. The elements of the target of the pointer object, in array
element order (6.5.3.2), are the first SIZE (data-pointer-object) elements of
the pointer target."

"C717 (R733) If bounds-remapping-list is specified, the number of
bounds-remappings shall equal the rank of data-pointer-object."


-- 


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


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

* [Bug fortran/29785] Fortran 2003: POINTER Rank Remapping
  2006-11-09 18:48 [Bug fortran/29785] New: Fortran 2003: POINTER Rank Remapping burnus at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2010-07-21  9:03 ` burnus at gcc dot gnu dot org
@ 2010-07-21  9:06 ` domob at gcc dot gnu dot org
  2010-07-21 10:14 ` burnus at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: domob at gcc dot gnu dot org @ 2010-07-21  9:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from domob at gcc dot gnu dot org  2010-07-21 09:06 -------
I'll work on this.


-- 

domob at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |domob at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2009-08-07 07:35:07         |2010-07-21 09:06:34
               date|                            |


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


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

* [Bug fortran/29785] Fortran 2003: POINTER Rank Remapping
  2006-11-09 18:48 [Bug fortran/29785] New: Fortran 2003: POINTER Rank Remapping burnus at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2010-07-21  9:06 ` domob at gcc dot gnu dot org
@ 2010-07-21 10:14 ` burnus at gcc dot gnu dot org
  2010-08-17 17:38 ` domob at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-07-21 10:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from burnus at gcc dot gnu dot org  2010-07-21 10:14 -------
See also PR 45016, which is not about bounds remapping but about setting the
correct bounds in an array assignment. (Wrong-code F95 bug + missing F2003
feature).

Maybe all three (remapping, fix bounds, F2003 lower bounds) can be fixed
simultaneously.


-- 


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


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

* [Bug fortran/29785] Fortran 2003: POINTER Rank Remapping
  2006-11-09 18:48 [Bug fortran/29785] New: Fortran 2003: POINTER Rank Remapping burnus at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2010-07-21 10:14 ` burnus at gcc dot gnu dot org
@ 2010-08-17 17:38 ` domob at gcc dot gnu dot org
  2010-08-17 18:21 ` mikael at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: domob at gcc dot gnu dot org @ 2010-08-17 17:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from domob at gcc dot gnu dot org  2010-08-17 17:38 -------
Tobias (and all):  Do you think we should check for "the size of data-target
shall not be less than the size of data-pointer-object" at runtime when
-fcheck=bounds is given?


-- 


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


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

* [Bug fortran/29785] Fortran 2003: POINTER Rank Remapping
  2006-11-09 18:48 [Bug fortran/29785] New: Fortran 2003: POINTER Rank Remapping burnus at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2010-08-17 17:38 ` domob at gcc dot gnu dot org
@ 2010-08-17 18:21 ` mikael at gcc dot gnu dot org
  2010-08-18 19:34 ` domob at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mikael at gcc dot gnu dot org @ 2010-08-17 18:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from mikael at gcc dot gnu dot org  2010-08-17 18:21 -------
(In reply to comment #7)
> Tobias (and all):  Do you think we should check for "the size of data-target
> shall not be less than the size of data-pointer-object" at runtime when
> -fcheck=bounds is given?
> 

Yes.
The existing bounds-check code checks that we don't access an array beyond what
its descriptor permits. 
We have to check that we don't create a descriptor that has bounds beyond the
array limits, thus by-passing the bounds-check code.


-- 


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


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

* [Bug fortran/29785] Fortran 2003: POINTER Rank Remapping
  2006-11-09 18:48 [Bug fortran/29785] New: Fortran 2003: POINTER Rank Remapping burnus at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2010-08-17 18:21 ` mikael at gcc dot gnu dot org
@ 2010-08-18 19:34 ` domob at gcc dot gnu dot org
  2010-08-19 16:03 ` domob at gcc dot gnu dot org
  2010-08-19 16:06 ` domob at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: domob at gcc dot gnu dot org @ 2010-08-18 19:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from domob at gcc dot gnu dot org  2010-08-18 19:34 -------
Created an attachment (id=21514)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21514&action=view)
Partial patch.

This implements rank remapping and also bounds remapping as for PR 45016. 
Tests seem to be successful, although it's not yet been fully regtested.

I still have to / want to add a compile-time and -fcheck=bounds test for too
small target.


-- 


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


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

* [Bug fortran/29785] Fortran 2003: POINTER Rank Remapping
  2006-11-09 18:48 [Bug fortran/29785] New: Fortran 2003: POINTER Rank Remapping burnus at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2010-08-18 19:34 ` domob at gcc dot gnu dot org
@ 2010-08-19 16:03 ` domob at gcc dot gnu dot org
  2010-08-19 16:06 ` domob at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: domob at gcc dot gnu dot org @ 2010-08-19 16:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from domob at gcc dot gnu dot org  2010-08-19 16:02 -------
Subject: Bug 29785

Author: domob
Date: Thu Aug 19 16:02:30 2010
New Revision: 163377

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163377
Log:
2010-08-19  Daniel Kraft  <d@domob.eu>

        PR fortran/29785
        PR fortran/45016
        * trans.h (struct gfc_se): New flag `byref_noassign'.
        * trans-array.h (gfc_conv_shift_descriptor_lbound): New method.
        (gfc_conv_array_extent_dim), (gfc_conv_descriptor_size): New methods.
        * expr.c (gfc_check_pointer_assign): Allow bounds and rank remapping
        and check for compile-time errors with those.
        * trans-decl.c (trans_associate_var): Use new routine
        `gfc_conv_shift_descriptor_lbound' instead of doing it manually.
        * trans-array.c (gfc_conv_shift_descriptor_lbound): New method.
        (gfc_conv_array_extent_dim), (gfc_conv_descriptor_size): New methods.
        (gfc_array_init_size): Use new `gfc_conv_array_extent_dim'.
        (gfc_conv_expr_descriptor): Handle new flag `byref_noassign'.
        * trans-expr.c (gfc_trans_pointer_assignment): Handle bounds and
        rank remapping for assignment.

2010-08-19  Daniel Kraft  <d@domob.eu>

        PR fortran/29785
        PR fortran/45016
        * gfortran.dg/pointer_assign_5.f90: Remove 'not implemented' error.
        * gfortran.dg/pointer_remapping_1.f90: New test.
        * gfortran.dg/pointer_remapping_2.f03: New test.
        * gfortran.dg/pointer_remapping_3.f08: New test.
        * gfortran.dg/pointer_remapping_4.f03: New test.
        * gfortran.dg/pointer_remapping_5.f08: New test.
        * gfortran.dg/pointer_remapping_6.f08: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/pointer_remapping_1.f90
    trunk/gcc/testsuite/gfortran.dg/pointer_remapping_2.f03
    trunk/gcc/testsuite/gfortran.dg/pointer_remapping_3.f08
    trunk/gcc/testsuite/gfortran.dg/pointer_remapping_4.f03
    trunk/gcc/testsuite/gfortran.dg/pointer_remapping_5.f08
    trunk/gcc/testsuite/gfortran.dg/pointer_remapping_6.f08
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/expr.c
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/fortran/trans-array.h
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/fortran/trans.h
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/pointer_assign_5.f90


-- 


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


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

* [Bug fortran/29785] Fortran 2003: POINTER Rank Remapping
  2006-11-09 18:48 [Bug fortran/29785] New: Fortran 2003: POINTER Rank Remapping burnus at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2010-08-19 16:03 ` domob at gcc dot gnu dot org
@ 2010-08-19 16:06 ` domob at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: domob at gcc dot gnu dot org @ 2010-08-19 16:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from domob at gcc dot gnu dot org  2010-08-19 16:06 -------
Fixed (with an extended version of the patch attached above).


-- 

domob at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2010-08-19 16:06 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-09 18:48 [Bug fortran/29785] New: Fortran 2003: POINTER Rank Remapping burnus at gcc dot gnu dot org
2006-11-09 18:48 ` [Bug fortran/29785] " burnus at gcc dot gnu dot org
2007-04-12  8:19 ` burnus at gcc dot gnu dot org
2008-07-03 16:10 ` burnus at gcc dot gnu dot org
2009-08-07  7:35 ` jv244 at cam dot ac dot uk
2010-07-21  9:03 ` burnus at gcc dot gnu dot org
2010-07-21  9:06 ` domob at gcc dot gnu dot org
2010-07-21 10:14 ` burnus at gcc dot gnu dot org
2010-08-17 17:38 ` domob at gcc dot gnu dot org
2010-08-17 18:21 ` mikael at gcc dot gnu dot org
2010-08-18 19:34 ` domob at gcc dot gnu dot org
2010-08-19 16:03 ` domob at gcc dot gnu dot org
2010-08-19 16:06 ` domob 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).