public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "burnus at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/45016] New: Support pointer assignment with bound-spec; wrong bounds for pointer assignment Date: Wed, 21 Jul 2010 10:12:00 -0000 [thread overview] Message-ID: <bug-45016-13404@http.gcc.gnu.org/bugzilla/> (raw) 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
next reply other threads:[~2010-07-21 10:12 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-07-21 10:12 burnus at gcc dot gnu dot org [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-45016-13404@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).