public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/34665]  New: Cannot pass scalar to array argument 'a'
@ 2008-01-03 21:44 jv244 at cam dot ac dot uk
  2008-01-04  7:21 ` [Bug fortran/34665] " burnus at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: jv244 at cam dot ac dot uk @ 2008-01-03 21:44 UTC (permalink / raw)
  To: gcc-bugs

The following is non-standard and the compiler should probably generate a
warning/error with '-pedantic -std=f95', but does not do so with
gcc version 4.3.0 20080103 (experimental) [trunk revision 131300] (GCC)

CONTAINS
SUBROUTINE S1(a)
 real, dimension(:) :: a
 call s2(a(1))
END SUBROUTINE S1
SUBROUTINE S2(a)
 real, dimension(*) :: a
END SUBROUTINE S2
END


-- 
           Summary: Cannot pass scalar to array argument 'a'
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jv244 at cam dot ac dot uk


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


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

* [Bug fortran/34665] Cannot pass scalar to array argument 'a'
  2008-01-03 21:44 [Bug fortran/34665] New: Cannot pass scalar to array argument 'a' jv244 at cam dot ac dot uk
@ 2008-01-04  7:21 ` burnus at gcc dot gnu dot org
  2008-01-04  9:39 ` tkoenig at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-01-04  7:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2008-01-04 07:11 -------
Confirm.

NAG f95 prints:
Error: Element of assumed-shape array A supplied for array argument A (no. 1)
of S2

ifort:
Error: If the actual argument is scalar, the corresponding dummy argument shall
be scalar unless the actual argument is an element of an array that is not an
assumed-shape or pointer array, or a substring of such an element.


-- 

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         |2008-01-04 07:11:38
               date|                            |


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


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

* [Bug fortran/34665] Cannot pass scalar to array argument 'a'
  2008-01-03 21:44 [Bug fortran/34665] New: Cannot pass scalar to array argument 'a' jv244 at cam dot ac dot uk
  2008-01-04  7:21 ` [Bug fortran/34665] " burnus at gcc dot gnu dot org
@ 2008-01-04  9:39 ` tkoenig at gcc dot gnu dot org
  2008-01-04 22:39 ` burnus at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2008-01-04  9:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from tkoenig at gcc dot gnu dot org  2008-01-04 09:26 -------
We catch this with an explicit interface, but we
should still check for occurrence in the
same source code.

Setting to "diagnostic" as we aren't required to catch this
(no constraint violation).


-- 

tkoenig at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
           Keywords|accepts-invalid             |diagnostic


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


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

* [Bug fortran/34665] Cannot pass scalar to array argument 'a'
  2008-01-03 21:44 [Bug fortran/34665] New: Cannot pass scalar to array argument 'a' jv244 at cam dot ac dot uk
  2008-01-04  7:21 ` [Bug fortran/34665] " burnus at gcc dot gnu dot org
  2008-01-04  9:39 ` tkoenig at gcc dot gnu dot org
@ 2008-01-04 22:39 ` burnus at gcc dot gnu dot org
  2008-01-05 16:13 ` tkoenig at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-01-04 22:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from burnus at gcc dot gnu dot org  2008-01-04 19:28 -------
> We catch this with an explicit interface, but we
> should still check for occurrence in the
> same source code.

I do not understand this part. There is an explicit interface available as both
are contained in the same main program.

>From Fortran 2003's "12.4.1.2 Actual arguments associated with dummy data
objects":

"If the actual argument is scalar, the corresponding dummy argument shall be
scalar unless the actual argument is of type default character, of type
character with the C character kind (15.1), or is an element or substring of an
element of an array that is not an assumed-shape or pointer array."

I think this has to be fixed in interface.c's compare_parameter.


-- 


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


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

* [Bug fortran/34665] Cannot pass scalar to array argument 'a'
  2008-01-03 21:44 [Bug fortran/34665] New: Cannot pass scalar to array argument 'a' jv244 at cam dot ac dot uk
                   ` (2 preceding siblings ...)
  2008-01-04 22:39 ` burnus at gcc dot gnu dot org
@ 2008-01-05 16:13 ` tkoenig at gcc dot gnu dot org
  2008-01-07  0:39 ` burnus at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2008-01-05 16:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from tkoenig at gcc dot gnu dot org  2008-01-05 14:57 -------
(In reply to comment #3)
> > We catch this with an explicit interface, but we
> > should still check for occurrence in the
> > same source code.
> 
> I do not understand this part. 

Ooops, you're correct.  Yes, we should catch this.


-- 


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


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

* [Bug fortran/34665] Cannot pass scalar to array argument 'a'
  2008-01-03 21:44 [Bug fortran/34665] New: Cannot pass scalar to array argument 'a' jv244 at cam dot ac dot uk
                   ` (3 preceding siblings ...)
  2008-01-05 16:13 ` tkoenig at gcc dot gnu dot org
@ 2008-01-07  0:39 ` burnus at gcc dot gnu dot org
  2008-01-12 15:34 ` burnus at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-01-07  0:39 UTC (permalink / raw)
  To: gcc-bugs



-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |burnus at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2008-01-04 07:11:38         |2008-01-06 23:33:27
               date|                            |


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


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

* [Bug fortran/34665] Cannot pass scalar to array argument 'a'
  2008-01-03 21:44 [Bug fortran/34665] New: Cannot pass scalar to array argument 'a' jv244 at cam dot ac dot uk
                   ` (4 preceding siblings ...)
  2008-01-07  0:39 ` burnus at gcc dot gnu dot org
@ 2008-01-12 15:34 ` burnus at gcc dot gnu dot org
  2008-01-12 21:45 ` burnus at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-01-12 15:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from burnus at gcc dot gnu dot org  2008-01-12 14:36 -------
A related but slightly separate issue is illustrated by the following example.
The argument of the second call to FOO is an expression; however, expressions
involving assumed-size arrays are evil. This is detected for assignments:
"Error: The upper bound in the last dimension must appear in the reference to
the assumed size array 'a' at (1)", but not for actual arguments.
(Note: Procedure calls are in so far different as passing the assumed-size
array itself it valid.)

subroutine one(a)
  external foo
  integer :: a(*)
  integer :: b
  call foo(a) ! ok
  call foo((a)) ! Wrong
  call foo(a+1) ! Wrong
  b = a+1 ! diagnosed as being invalid
end subroutine


-- 


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


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

* [Bug fortran/34665] Cannot pass scalar to array argument 'a'
  2008-01-03 21:44 [Bug fortran/34665] New: Cannot pass scalar to array argument 'a' jv244 at cam dot ac dot uk
                   ` (5 preceding siblings ...)
  2008-01-12 15:34 ` burnus at gcc dot gnu dot org
@ 2008-01-12 21:45 ` burnus at gcc dot gnu dot org
  2008-01-13 17:58 ` burnus at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-01-12 21:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from burnus at gcc dot gnu dot org  2008-01-12 21:13 -------
One has to be careful not to to get the same problem as with SHAPE in PR 34759,
i.e. passing a rank-2 array A(:,:,5) defined as rank-3 assumed-shape array
A(:,:,*).


-- 


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


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

* [Bug fortran/34665] Cannot pass scalar to array argument 'a'
  2008-01-03 21:44 [Bug fortran/34665] New: Cannot pass scalar to array argument 'a' jv244 at cam dot ac dot uk
                   ` (6 preceding siblings ...)
  2008-01-12 21:45 ` burnus at gcc dot gnu dot org
@ 2008-01-13 17:58 ` burnus at gcc dot gnu dot org
  2008-01-13 21:55 ` burnus at gcc dot gnu dot org
  2008-01-13 22:16 ` burnus at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-01-13 17:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from burnus at gcc dot gnu dot org  2008-01-13 17:41 -------
> One has to be careful not to to get the same problem as with SHAPE in PR 34759,
> i.e. passing a rank-2 array A(:,:,5) defined as rank-3 assumed-shape array
> A(:,:,*).
This is actually already properly handled.

Patch: http://gcc.gnu.org/ml/gcc-patches/2008-01/msg00570.html


-- 


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


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

* [Bug fortran/34665] Cannot pass scalar to array argument 'a'
  2008-01-03 21:44 [Bug fortran/34665] New: Cannot pass scalar to array argument 'a' jv244 at cam dot ac dot uk
                   ` (7 preceding siblings ...)
  2008-01-13 17:58 ` burnus at gcc dot gnu dot org
@ 2008-01-13 21:55 ` burnus at gcc dot gnu dot org
  2008-01-13 22:16 ` burnus at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-01-13 21:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from burnus at gcc dot gnu dot org  2008-01-13 21:36 -------
Subject: Bug 34665

Author: burnus
Date: Sun Jan 13 21:35:33 2008
New Revision: 131513

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131513
Log:
2008-01-13  Tobias Burnus  <burnus@net-b.de>

        PR fortran/34665
        * resolve.c (resolve_actual_arglist): For expressions,
        also check for assume-sized arrays.
        * interface.c (compare_parameter): Move F2003 character checks
        here, print error messages here, reject elements of
        assumed-shape array as argument to dummy arrays.
        (compare_actual_formal): Update for the changes above.

2008-01-13  Tobias Burnus  <burnus@net-b.de>

        PR fortran/34665
        * gfortran.dg/argument_checking_11.f90: New.
        * gfortran.dg/argument_checking_12.f90: New.
        * gfortran.dg/used_dummy_types_4.f90: Update dg-error.
        * gfortran.dg/c_assoc_2.f03: Update dg-error.
        * gfortran.dg/argument_checking_3.f90: Ditto.
        * gfortran.dg/pointer_intent_2.f90: Ditto.
        * gfortran.dg/import2.f90: Ditto.
        * gfortran.dg/assumed_shape_ranks_1.f90: Ditto.
        * gfortran.dg/implicit_actual.f90: Ditto.
        * gfortran.dg/used_dummy_types_3.f90: Ditto.
        * gfortran.dg/derived_comp_array_ref_6.f90: Ditto.


Added:
    trunk/gcc/testsuite/gfortran.dg/argument_checking_11.f90
    trunk/gcc/testsuite/gfortran.dg/argument_checking_12.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/interface.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/argument_checking_3.f90
    trunk/gcc/testsuite/gfortran.dg/assumed_shape_ranks_1.f90
    trunk/gcc/testsuite/gfortran.dg/c_assoc_2.f03
    trunk/gcc/testsuite/gfortran.dg/derived_comp_array_ref_6.f90
    trunk/gcc/testsuite/gfortran.dg/implicit_actual.f90
    trunk/gcc/testsuite/gfortran.dg/import2.f90
    trunk/gcc/testsuite/gfortran.dg/pointer_intent_2.f90
    trunk/gcc/testsuite/gfortran.dg/used_dummy_types_3.f90
    trunk/gcc/testsuite/gfortran.dg/used_dummy_types_4.f90


-- 


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


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

* [Bug fortran/34665] Cannot pass scalar to array argument 'a'
  2008-01-03 21:44 [Bug fortran/34665] New: Cannot pass scalar to array argument 'a' jv244 at cam dot ac dot uk
                   ` (8 preceding siblings ...)
  2008-01-13 21:55 ` burnus at gcc dot gnu dot org
@ 2008-01-13 22:16 ` burnus at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-01-13 22:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from burnus at gcc dot gnu dot org  2008-01-13 21:49 -------
Fixed on the trunk (4.3.0).

Thanks for the report!


-- 

burnus at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2008-01-13 21:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-03 21:44 [Bug fortran/34665] New: Cannot pass scalar to array argument 'a' jv244 at cam dot ac dot uk
2008-01-04  7:21 ` [Bug fortran/34665] " burnus at gcc dot gnu dot org
2008-01-04  9:39 ` tkoenig at gcc dot gnu dot org
2008-01-04 22:39 ` burnus at gcc dot gnu dot org
2008-01-05 16:13 ` tkoenig at gcc dot gnu dot org
2008-01-07  0:39 ` burnus at gcc dot gnu dot org
2008-01-12 15:34 ` burnus at gcc dot gnu dot org
2008-01-12 21:45 ` burnus at gcc dot gnu dot org
2008-01-13 17:58 ` burnus at gcc dot gnu dot org
2008-01-13 21:55 ` burnus at gcc dot gnu dot org
2008-01-13 22:16 ` burnus 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).