* [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