public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/41603]  New: [-fwhole-file] Add diagnostic for assumed-length character function
@ 2009-10-06 14:26 burnus at gcc dot gnu dot org
  2009-10-06 14:27 ` [Bug fortran/41603] " burnus at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-10-06 14:26 UTC (permalink / raw)
  To: gcc-bugs

Found in the thread
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/bb75425678569ae3
James Van Buskirk wrote a program there in
http://groups.google.com/group/comp.lang.fortran/msg/fb12cca32eab44cb

The program seems to be invalid with the interface declaration.

ifort -warn all writes:

test.f90(58): warning #7984: 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. No interface block will be generated.   [ASSUMED_LEN]
function assumed_len(x)
---------^

NAG f95 writes:

Error: ahjf.f90: Assumed-length character function ASSUMED_LEN described in an
INTERFACE block in FUNCS as non-assumed

Expected: With "gfortran -std=f2003 -Wall -pedantic -fwhole-file ahjf.f90" one
should see also some diagnostic


-- 
           Summary: [-fwhole-file] Add diagnostic for assumed-length
                    character function
           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=41603


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

* [Bug fortran/41603] [-fwhole-file] Add diagnostic for assumed-length character function
  2009-10-06 14:26 [Bug fortran/41603] New: [-fwhole-file] Add diagnostic for assumed-length character function burnus at gcc dot gnu dot org
@ 2009-10-06 14:27 ` burnus at gcc dot gnu dot org
  2009-10-06 14:57 ` burnus at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-10-06 14:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2009-10-06 14:27 -------
Created an attachment (id=18725)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18725&action=view)
testcase


-- 


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


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

* [Bug fortran/41603] [-fwhole-file] Add diagnostic for assumed-length character function
  2009-10-06 14:26 [Bug fortran/41603] New: [-fwhole-file] Add diagnostic for assumed-length character function burnus at gcc dot gnu dot org
  2009-10-06 14:27 ` [Bug fortran/41603] " burnus at gcc dot gnu dot org
@ 2009-10-06 14:57 ` burnus at gcc dot gnu dot org
  2009-10-06 15:01 ` burnus at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-10-06 14:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2009-10-06 14:57 -------
See also PR 41604.

I actually cannot find the spot in the standard which renders this example as
invalid. Reading the following excerpt, I have even the feeling that it is
valid:


"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)


As NAG f95 does not diagnose the problem in PR 41604 and ifort (-warn all)
talks about "interface" although there is no interface, the diagnostics might
be bogus.

 * * *

Richard Maine wrote in the thread at comp.lang.fortran:

"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"

The question is only whether an explicit interface is not allowed (as the
compiler error implies) or that the explicit interface may not use a "*"

 * * *

Maybe one could argue the following for disallowing the interfaces:

a) "12.2.2 Characteristics of function results": "If the length of a character
function result is assumed, this is a characteristic."

b) "An interface body specifies all of the characteristics of the explicit
specific interface or abstract interface."

c) "If an explicit specific interface is specified by an interface body or a
procedure declaration statement (12.3.2.3) for an external procedure, the
characteristics shall be consistent with those specified in the procedure
definition, except that the interface may specify a procedure that is not pure
if the procedure is defined to be pure."


If the latter is the correct reading then one needs to have an implicit
interface with a character length (which is not "*, cf. PR 41604), but using an
explicit interface is not allowed.


-- 


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


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

* [Bug fortran/41603] [-fwhole-file] Add diagnostic for assumed-length character function
  2009-10-06 14:26 [Bug fortran/41603] New: [-fwhole-file] Add diagnostic for assumed-length character function burnus at gcc dot gnu dot org
  2009-10-06 14:27 ` [Bug fortran/41603] " burnus at gcc dot gnu dot org
  2009-10-06 14:57 ` burnus at gcc dot gnu dot org
@ 2009-10-06 15:01 ` burnus at gcc dot gnu dot org
  2009-10-06 17:56 ` burnus at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-10-06 15:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from burnus at gcc dot gnu dot org  2009-10-06 15:01 -------
(In reply to comment #2)
> If the latter is the correct reading then one needs to have an implicit
> interface with a character length (which is not "*, cf. PR 41604), but using
> an explicit interface is not allowed.

That's also in line with NAG f95. If one replaces the interface block by
         external assumed_len
         character(4) assumed_len
NAG f95 compiles without error.

("ifort -warn all" still gives the same bogus warning as in comment 0. The
warning for the related but different construct at PR 41604 seems to be correct
and it is only printed by ifort.)


-- 


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


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

* [Bug fortran/41603] [-fwhole-file] Add diagnostic for assumed-length character function
  2009-10-06 14:26 [Bug fortran/41603] New: [-fwhole-file] Add diagnostic for assumed-length character function burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2009-10-06 15:01 ` burnus at gcc dot gnu dot org
@ 2009-10-06 17:56 ` burnus at gcc dot gnu dot org
  2009-10-07  8:02 ` burnus at gcc dot gnu dot org
  2009-10-14 16:10 ` burnus at gcc dot gnu dot org
  5 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-10-06 17:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from burnus at gcc dot gnu dot org  2009-10-06 17:55 -------
(In reply to comment #2)
> c) "If an explicit specific interface is specified by an interface body or a
> procedure declaration statement (12.3.2.3) for an external procedure, the
> characteristics shall be consistent with those specified in the procedure
> definition

Richard Main thinks that this disallows it:

'The special rule for assumed length says that this characteristic has to be
 different, but this requirement says that the characteristic has to be
 "consistent." I do wish that were defined better, but from context hints
 I'd interpret "consistent" to mean "the same" for yes/no characteristics
 like assumed character length. If one tried to interpret "consistent"
 differently here, I'd wonder why that same interpretation wouldn't apply
 to the purity matter cited as an exception.

'I suppose there is some ground for uncertainly here based on the
 question of exactly how "consistent" is interpreted.'

I still do not quite see why it is allowed for implicit interfaces, but somehow
the following seems to allow it:

"If a type is specified for an external function, its function definition
(12.5.2.1) shall specify the same result type and type parameters."

(If it weren't allowed then one could not use it at all. And as it is a legacy
item, it must work without explicit interfaces which only exists since F90.)

Cf. http://groups.google.com/group/comp.lang.fortran/msg/3ea113a7b45471e5


-- 


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


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

* [Bug fortran/41603] [-fwhole-file] Add diagnostic for assumed-length character function
  2009-10-06 14:26 [Bug fortran/41603] New: [-fwhole-file] Add diagnostic for assumed-length character function burnus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2009-10-06 17:56 ` burnus at gcc dot gnu dot org
@ 2009-10-07  8:02 ` burnus at gcc dot gnu dot org
  2009-10-14 16:10 ` burnus at gcc dot gnu dot org
  5 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-10-07  8:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from burnus at gcc dot gnu dot org  2009-10-07 08:02 -------
More from the thread.

Richard Maine wrote:

  The Note appears to have been removed from f2003, but see
  F95 Note 5.6. Apparently it was the interface body case I was recalling
  rather than the module procedure case.

  "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 *."

   Well, I agree that the wording isn't as clear as I'd like. And I do note
   the switch from "consistent" to "same" in the above Note.

James Van Buskirk remarked "It seems possible to me that the Note was removed
   in the next edition because it was simply incorrect, not having been vetted
   to the same standard as normative text in the first place."

And Richard replied: "Granted"

(At least F2003 deprecates assumed-length functions: They are printed in 
smaller font size, which might be a reason for removal of the note.)

 * * *

One pragmatic solution would be to close this PR a won't fix and only fix the
items in PR 41604.


-- 


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


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

* [Bug fortran/41603] [-fwhole-file] Add diagnostic for assumed-length character function
  2009-10-06 14:26 [Bug fortran/41603] New: [-fwhole-file] Add diagnostic for assumed-length character function burnus at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2009-10-07  8:02 ` burnus at gcc dot gnu dot org
@ 2009-10-14 16:10 ` burnus at gcc dot gnu dot org
  5 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-10-14 16:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from burnus at gcc dot gnu dot org  2009-10-14 16:10 -------
Just for completeness: The wording in
  J3/04-007 (p. 259, ll. 38-41; "12.3.2.1 Interface block")
and in
  J3/97-007r2 (p. 194, ll. 32-34)
is effectively the same. Thus there does not seem to be any change in the
normative text. Assuming that there is none, I think concluding that the note
still holds in F2003 is likely. I think I follow this line of thought and do
not hand in an interpretation request.

If someone does not think so, we can still do so - an IR is only little work
for us and does also not take so much work in this case for J3/WG5.


-- 


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


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

* [Bug fortran/41603] [-fwhole-file] Add diagnostic for assumed-length character function
       [not found] <bug-41603-4@http.gcc.gnu.org/bugzilla/>
@ 2011-03-13 15:54 ` pault at gcc dot gnu.org
  0 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu.org @ 2011-03-13 15:54 UTC (permalink / raw)
  To: gcc-bugs

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

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |pault at gcc dot gnu.org
         Resolution|                            |WONTFIX

--- Comment #7 from Paul Thomas <pault at gcc dot gnu.org> 2011-03-13 15:54:19 UTC ---
(In reply to comment #6)
> Just for completeness: The wording in
>   J3/04-007 (p. 259, ll. 38-41; "12.3.2.1 Interface block")
> and in
>   J3/97-007r2 (p. 194, ll. 32-34)
> is effectively the same. Thus there does not seem to be any change in the
> normative text. Assuming that there is none, I think concluding that the note
> still holds in F2003 is likely. I think I follow this line of thought and do
> not hand in an interpretation request.
> 
> If someone does not think so, we can still do so - an IR is only little work
> for us and does also not take so much work in this case for J3/WG5.

Dear Tobias,

I think that this is a WONTFIX.  Please reopen it if you disagree.

Cheers

Paul


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

end of thread, other threads:[~2011-03-13 15:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-06 14:26 [Bug fortran/41603] New: [-fwhole-file] Add diagnostic for assumed-length character function burnus at gcc dot gnu dot org
2009-10-06 14:27 ` [Bug fortran/41603] " burnus at gcc dot gnu dot org
2009-10-06 14:57 ` burnus at gcc dot gnu dot org
2009-10-06 15:01 ` burnus at gcc dot gnu dot org
2009-10-06 17:56 ` burnus at gcc dot gnu dot org
2009-10-07  8:02 ` burnus at gcc dot gnu dot org
2009-10-14 16:10 ` burnus at gcc dot gnu dot org
     [not found] <bug-41603-4@http.gcc.gnu.org/bugzilla/>
2011-03-13 15:54 ` pault at gcc dot gnu.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).