Bug 45859 - [Coarray, F2008, IR] Rejects valid actuals to coarray dummies
Summary: [Coarray, F2008, IR] Rejects valid actuals to coarray dummies
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks: 39627 18918
  Show dependency treegraph
 
Reported: 2010-10-01 15:55 UTC by Tobias Burnus
Modified: 2015-12-14 13:19 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-10-20 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2010-10-01 15:55:28 UTC
The discussion has started at
   http://j3-fortran.org/pipermail/j3/2010-September/003862.html
and lead to the following interpretation request (no link as the mail archive lags behind).

The program
   interface
      subroutine sub (x)
         real x(10)[*]
      end subroutine
   end interface
   real :: x(100)[*]
   call sub (x(10))
   end

is supposed to be valid according the following IR. A modified program which uses
   call sub (x(10:))
is unambiguously valid. However, both programs are rejected by:

   call sub (x(10))
              1
Error: Actual argument to 'x' at (1) must be a coarray and thus shall not have an array designator

------------------------------------------------------
To: J3                                                     10-xxx
From: John Reid
Subject: F2008 interp re sequence association for coarrays
Date: 2010 October 1

NUMBER: F08/xxxx
TITLE:  Sequence association for coarrays
KEYWORDS: sequence association, coarrays
DEFECT TYPE: Erratum
STATUS: J3 consideration in progress

QUESTION:

Was the text in 12.5.2.8:
"If the dummy argument is an array coarray that has the CONTIGUOUS 
attribute or is not of assumed shape, the corresponding actual argument 
shall be simply contiguous." 
intended to disallow sequence association for coarrays, as 
illustrated by the example

   interface
      subroutine sub (x)
         real x(10)[*]
      end subroutine
   end interface
   ...
   real :: x(100)[*]
   ...
   call sub (x(10)) 

ANSWER:

No. This restriction contradicts 12.5.2.4 paragraph 13, which allows 
the example program. An edit is supplied to correct this.

EDIT:

In 12.5.2.8 Coarray dummy variables, at the end of paragraph 2, 
add "or an element of a simply contiguous array".

SUBMITTED BY: John Reid
Comment 1 Tobias Burnus 2011-03-27 16:03:41 UTC
See "F08/0040" at http://j3-fortran.org/doc/year/11/11-006A.txt
"STATUS: Passed by J3 letter ballot"
Comment 2 Tobias Burnus 2011-07-18 20:16:08 UTC
(In reply to comment #1)
> See "F08/0040" at http://j3-fortran.org/doc/year/11/11-006A.txt
> "STATUS: Passed by J3 letter ballot"

My comment is odd. First, the number is wrong. It's F08/0048. Secondly, the proposal was rejected at the voting.

It gets muddier if one looks at the details:
Meeting 193 ( http://j3-fortran.org/doc/meeting/193/ ):
- 10-229 has an edit which allows the program (cf. quote in comment 0)
- 10-229r1 and 10-229r2 has an edit which makes the program invalid
- The letter ballot (cf. 11-129 of meeting m194 and link of comment 1) rejected
  the 10-229r2 version - and suggested in comment the wording of 10-229.

The IR has seemingly not been picked up again for later meetings. I have now
asked at J3 for an update.
Comment 3 Tobias Burnus 2011-07-18 20:21:20 UTC
(In reply to comment #2)
> Meeting 193 ( http://j3-fortran.org/doc/meeting/193/ ):
> - 10-229 has an edit which allows the program (cf. quote in comment 0)
> - 10-229r1 and 10-229r2

Make those 10-226, 10-226r1 and 226r2.
Comment 4 Tobias Burnus 2011-08-25 14:28:03 UTC
(In reply to comment #0)
> is supposed to be valid according the following IR. A modified program which
> uses
>    call sub (x(10:))
> is unambiguously valid. However, both programs are rejected by:

With current gfortran 4.7, the "x(10:)" program is accepted and the other one is rejected for "x(10)" with "must be simply contiguous" (which is true). Thus, the result is OK and only depends on what J3/WG5 regard as correct.

TODO: Wait for the result of the IR.
Comment 5 Dominique d'Humieres 2015-10-20 16:45:30 UTC
> With current gfortran 4.7, the "x(10:)" program is accepted and the other
> one is rejected for "x(10)" with "must be simply contiguous" (which is true).
> Thus, the result is OK and only depends on what J3/WG5 regard as correct.

Confirmed from 4.8 up to trunk (6.0).

> TODO: Wait for the result of the IR.

From my version of the Fortran 2015 draft

12.5.2.8 Coarray dummy variables

...

2 If the dummy argument is an array coarray that has the CONTIGUOUS attribute
  or is not of assumed shape, the corresponding actual argument shall be simply
  contiguous or an element of a simply contiguous array.

Does it means that gfortran is correct?
Comment 6 Tobias Burnus 2015-12-04 10:26:30 UTC
(In reply to Dominique d'Humieres from comment #5)
> > TODO: Wait for the result of the IR.

It's now available under "F08/0048" at ftp://ftp.nag.co.uk/sc22wg5/N1951-N2000/N1959.txt - published as Corrigendum 2 to Fortran 2008.

> From my version of the Fortran 2015 draft
> 2 If the dummy argument is an array coarray that has the CONTIGUOUS attribute
>   or is not of assumed shape, the corresponding actual argument shall be
> simply
>   contiguous or an element of a simply contiguous array.
> 
> Does it means that gfortran is correct?

No - the code is valid. The added wording was "an element of a simply contiguous array" - and the example from comment 0 ("call sub (x(10))") is the latter.
Comment 7 Tobias Burnus 2015-12-12 19:01:04 UTC
Author: burnus
Date: Sat Dec 12 19:00:32 2015
New Revision: 231585

URL: https://gcc.gnu.org/viewcvs?rev=231585&root=gcc&view=rev
Log:
2014-12-12  Tobias Burnus  <burnus@net-b.de>

gcc/fortran
        PR fortran/45859
        * expr.c (gfc_is_simply_contiguous): Optionally permit array
        * elements.
        (gfc_check_pointer_assign): Update call.
        * interface.c (compare_parameter): Ditto.
        * trans-array.c (gfc_conv_array_parameter): Ditto.
        * trans-intrinsic.c (gfc_conv_intrinsic_transfer,
        conv_isocbinding_function): Ditto.
        * gfortran.h (gfc_is_simply_contiguous): Update prototype.

gcc/testsuite/
        PR fortran/45859
        * gcc/testsuite/gfortran.dg/coarray_args_2.f90: Remove dg-error.


Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/expr.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/interface.c
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/coarray_args_2.f90
Comment 8 Tobias Burnus 2015-12-14 13:19:24 UTC
FIXED in GCC 6