public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/41604]  New: Reject result with assumed-length character in INTERFACE decl
@ 2009-10-06 14:43 burnus at gcc dot gnu dot org
  2009-10-06 15:32 ` [Bug fortran/41604] " burnus at gcc dot gnu dot org
  2009-10-07  8:09 ` burnus at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-10-06 14:43 UTC (permalink / raw)
  To: gcc-bugs

Related to PR 41603 but easier to diagnose:

   interface
      function assumed_len(x)
         character(*) assumed_len
         integer, intent(in) :: x
      end function assumed_len
   end interface
   end

ifort claims:

test.f90(2): error #6286: A CHARACTER function name must not be declared with
an asterisk type-param-value (i.e., (LEN=*)) if the function is part of an
interface-body.   [ASSUMED_LEN]
      function assumed_len(x)
---------------^


While other compilers do not complain, I think Intel is right:

"A char-length type parameter value of * has the following meaning: [...]
(4) If used to specify the character length parameter of a function result, any
scoping unit invoking the function shall declare the function name with a
character length parameter value other than * or access such a definition by
host or use association. When the function is invoked, the length of the result
variable in the function is assumed from the value of this type parameter."
(F2003, 4.4.4.1 Character type specifier)

See also thread at
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/bb75425678569ae3

There Richard Maine wrote:

"If a call was legal before, it is still legal with an explicit interface
(almost always*). [...]
The exceptions are arcane, mostly involving some obscure things that
are basically incompatible with having an explicit interface. The only
one I can think of at the moment is assumed-length character function
results"


-- 
           Summary: Reject result with assumed-length character in INTERFACE
                    decl
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid, diagnostic
          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=41604


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

* [Bug fortran/41604] Reject result with assumed-length character in INTERFACE decl
  2009-10-06 14:43 [Bug fortran/41604] New: Reject result with assumed-length character in INTERFACE decl burnus at gcc dot gnu dot org
@ 2009-10-06 15:32 ` burnus at gcc dot gnu dot org
  2009-10-07  8:09 ` burnus at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-10-06 15:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2009-10-06 15:31 -------
Actually, if one tries to use the function, one also gets with gfortran an
error message:

   c = assumed_len(5)
       1
Error: Function 'assumed_len' is declared CHARACTER(*) and cannot be used at
(1) since it is not a dummy argument


-- 


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


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

* [Bug fortran/41604] Reject result with assumed-length character in INTERFACE decl
  2009-10-06 14:43 [Bug fortran/41604] New: Reject result with assumed-length character in INTERFACE decl burnus at gcc dot gnu dot org
  2009-10-06 15:32 ` [Bug fortran/41604] " burnus at gcc dot gnu dot org
@ 2009-10-07  8:09 ` burnus at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-10-07  8:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2009-10-07 08:09 -------
Actually, according to a note (cf. PR 41603 comment 5) the interface actually
could be valid - as long it is not used.

While invoking the function directly is properly rejected, e.g. the following
  c = assumed_len(5)

using it as dummy is accepted:

 module funcs
   implicit none
   integer, parameter :: dp = kind(0.0)
   interface
      function assumed_len(x)
         character(*) assumed_len
         integer, intent(in) :: x
      end function assumed_len
   end interface
contains
  subroutine foo(x)
    procedure(assumed_len) :: x !!! Invalid?!
    ! Check also using an "interface" directly
  end subroutine
  subroutine test()
    call foo(assumed_len)
  end subroutine test
end module funcs



NAG f95 rejects it with:
Error: line 12: ASSUMED_LEN has an implicit interface, therefore it cannot be
used as a proc-interface

while Ifort as mentioned above already does not like the interface.

F95 had Note 5.6 (which is no longer in F2003):

  "An interface body may be specified for a dummy or external function
   whose result has a character length parameter of * only if the function
   is not invoked. This is because this characteristic has to be specified
   to be the same in the interface body as in the procedure definition, but
   in order to invoke such a procedure, the calling routine is required to
   specify a length other than *."


-- 


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


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

end of thread, other threads:[~2009-10-07  8:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-06 14:43 [Bug fortran/41604] New: Reject result with assumed-length character in INTERFACE decl burnus at gcc dot gnu dot org
2009-10-06 15:32 ` [Bug fortran/41604] " burnus at gcc dot gnu dot org
2009-10-07  8:09 ` 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).