public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/45016]  New: Support pointer assignment with bound-spec; wrong bounds for pointer assignment
@ 2010-07-21 10:12 burnus at gcc dot gnu dot org
  2010-07-21 10:18 ` [Bug fortran/45016] [4.6 Regression] " burnus at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-07-21 10:12 UTC (permalink / raw)
  To: gcc-bugs

This PR is about two related topics:
a) Wrong code: Fortran 90+: The lower bound shall be the same as the one of the
object on the RHS
b) F2003+ pointer assignment with bounds-spec

Related to PR 29785 (bounds remapping).

 * * *

a) WRONG CODE

The test case should print twice a lower bound of 2, but currently it prints
"1" for the lower bound of pointer "p":

!-------------------------------
integer, target :: a(2:5,2:5)
integer, pointer :: p(:,:)
!p(-1:,-1:) => a
p => a
print *, 'a: ', lbound(a)
print *, 'p: ', lbound(p)
end
!-------------------------------


Fortran 90 has:

"R736 pointer-assignment-stmt is pointer-object => target"
"If the target is not a pointer, the
pointer assignment statement associates the pointer-object with the target. If
the target is a pointer that is associated, the pointer-object is associated
with the same object as the target."

Due to the bounds-spec (cf. below) Fortran 2003 is more explicit:

"[...] the extent of a dimension of data-pointer-object is the extent of the
corresponding dimension of data-target. [...] the lower bound of each dimension
is the result of the intrinsic function LBOUND (13.7.60) applied to the
corresponding dimension of data-target. The upper bound of each dimension is
one less than the sum of the lower bound and the extent."

b) BOUND SPEC

(cf. 1.7 in the F2003 intro at
ftp://ftp.nag.co.uk/sc22wg5/N1601-N1650/N1648.pdf)

The following program should have a lower bound of "-1" for the pointer "p".
(Works, e.g., with the Cray compiler.)

Older gfortrans, e.g. 4.3, accepted this and set the lower bound to 1. Current
gfortran reports:
  Error: Pointer assignment to non-POINTER at (1)

!--------------------------------
integer, target :: a(2:5,2:5)
integer, pointer :: p(:,:)
p(-1:,-1:) => a
print *, 'a: ', lbound(a) ! OK, prints "2 2"
print *, 'p: ', lbound(p) ! WRONG: prints "1 1", expected: "-1 -1"
end
!--------------------------------

While Fortran 95 only has:
"R736 pointer-assignment-stmt  is  pointer-object => target"

Fortran 2003 (and F2008 as R733) have:
"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"

Further Fortran 2008 quotes (mostly identical to F2003, cf. also item (a)):

C716 (R733) If bounds-spec-list is specified, the number of bounds-specs shall
equal the rank of data-pointer-object.

C718 (R733) If bounds-remapping-list is not specified, the ranks of
data-pointer-object and data-target shall be the same.

R735 bounds-spec   is   lower-bound-expr :

[Remark: Note that only a lower bound can be specified; no upper or stride]

"If no bounds-remapping-list is specified, the extent of a dimension of the
pointer object is the extent of the corresponding dimension of the pointer
target. If bounds-spec-list appears, it specifies the lower bounds; otherwise,
the lower bound of each dimension is the result of the intrinsic function
LBOUND (13.7.90) applied to the corresponding dimension of the pointer target.
The upper bound of each dimension is one less than the sum of
the lower bound and the extent."

Expected: The bounds are correctly set. Additionally, the bounds are rejected
with -std=f95,


-- 
           Summary: Support pointer assignment with bound-spec; wrong bounds
                    for pointer assignment
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


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

* [Bug fortran/45016] [4.6 Regression] Support pointer assignment with bound-spec; wrong bounds for pointer assignment
  2010-07-21 10:12 [Bug fortran/45016] New: Support pointer assignment with bound-spec; wrong bounds for pointer assignment burnus at gcc dot gnu dot org
@ 2010-07-21 10:18 ` burnus at gcc dot gnu dot org
  2010-07-21 10:26 ` [Bug fortran/45016] " burnus at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-07-21 10:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2010-07-21 10:18 -------
Mark as regression; for "p => a" GCC 4.3.2 prints the correct bounds ("2 2"). I
currently cannot try 4.4 or 4.5.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.1.2 4.6.0
      Known to work|                            |4.3.2
            Summary|Support pointer assignment  |[4.6 Regression] Support
                   |with bound-spec; wrong      |pointer assignment with
                   |bounds for pointer          |bound-spec; wrong bounds for
                   |assignment                  |pointer assignment


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


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

* [Bug fortran/45016] Support pointer assignment with bound-spec; wrong bounds for pointer assignment
  2010-07-21 10:12 [Bug fortran/45016] New: Support pointer assignment with bound-spec; wrong bounds for pointer assignment burnus at gcc dot gnu dot org
  2010-07-21 10:18 ` [Bug fortran/45016] [4.6 Regression] " burnus at gcc dot gnu dot org
@ 2010-07-21 10:26 ` burnus at gcc dot gnu dot org
  2010-08-17 16:01 ` domob at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-07-21 10:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2010-07-21 10:26 -------
Scratch the regression thing. (a) Works also with 4.6. I accidentally was
running 4.1.2 (system compiler, "gfortran") instead of 4.6.0 ("gfortran46").
[On my usual system "gfortran" = 4.6.]

However, (b) is still true.  Sorry for the confusion!


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|wrong-code                  |
      Known to fail|4.1.2 4.6.0                 |
      Known to work|4.3.2                       |
            Summary|[4.6 Regression] Support    |Support pointer assignment
                   |pointer assignment with     |with bound-spec; wrong
                   |bound-spec; wrong bounds for|bounds for pointer
                   |pointer assignment          |assignment


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


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

* [Bug fortran/45016] Support pointer assignment with bound-spec; wrong bounds for pointer assignment
  2010-07-21 10:12 [Bug fortran/45016] New: Support pointer assignment with bound-spec; wrong bounds for pointer assignment burnus at gcc dot gnu dot org
  2010-07-21 10:18 ` [Bug fortran/45016] [4.6 Regression] " burnus at gcc dot gnu dot org
  2010-07-21 10:26 ` [Bug fortran/45016] " burnus at gcc dot gnu dot org
@ 2010-08-17 16:01 ` domob at gcc dot gnu dot org
  2010-08-19 16:03 ` domob at gcc dot gnu dot org
  2010-08-19 16:07 ` domob at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: domob at gcc dot gnu dot org @ 2010-08-17 16:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from domob at gcc dot gnu dot org  2010-08-17 16:00 -------
Also working on this, as suggested by Tobias in PR 29785 maybe this can be done
together.


-- 

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|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-08-17 16:00:55
               date|                            |


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


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

* [Bug fortran/45016] Support pointer assignment with bound-spec; wrong bounds for pointer assignment
  2010-07-21 10:12 [Bug fortran/45016] New: Support pointer assignment with bound-spec; wrong bounds for pointer assignment burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2010-08-17 16:01 ` domob at gcc dot gnu dot org
@ 2010-08-19 16:03 ` domob at gcc dot gnu dot org
  2010-08-19 16:07 ` domob at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: domob at gcc dot gnu dot org @ 2010-08-19 16:03 UTC (permalink / raw)
  To: gcc-bugs



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

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=45016


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

* [Bug fortran/45016] Support pointer assignment with bound-spec; wrong bounds for pointer assignment
  2010-07-21 10:12 [Bug fortran/45016] New: Support pointer assignment with bound-spec; wrong bounds for pointer assignment burnus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2010-08-19 16:03 ` domob at gcc dot gnu dot org
@ 2010-08-19 16:07 ` domob at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: domob at gcc dot gnu dot org @ 2010-08-19 16:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from domob at gcc dot gnu dot org  2010-08-19 16:07 -------
Fixed the lower bounds remapping, and the F95 issue claimed was already
working.  Thus closing.


-- 

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=45016


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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-21 10:12 [Bug fortran/45016] New: Support pointer assignment with bound-spec; wrong bounds for pointer assignment burnus at gcc dot gnu dot org
2010-07-21 10:18 ` [Bug fortran/45016] [4.6 Regression] " burnus at gcc dot gnu dot org
2010-07-21 10:26 ` [Bug fortran/45016] " burnus at gcc dot gnu dot org
2010-08-17 16:01 ` domob at gcc dot gnu dot org
2010-08-19 16:03 ` domob at gcc dot gnu dot org
2010-08-19 16:07 ` 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).