This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, Fortran] PR 39735: procedure pointer assignments: return value is not checked


Hi,

I committed the patch as r146554.


>>> Related to checking but unrelated to your patch: I think the following
>>> program is valid but it is rejected by gfortran (4.1 to 4.4 + patched
>>> 4.5). It works with NAG f95, g95, ifort, openf95 and sunf95:
>>>
>>> real function func()
>>> ?func = 42.0
>>> end function func
>>>
>>> program test
>>> ?external func ?! subroutine or implicitly typed real function
>>> ?call sub(func) ! Error: Type/rank mismatch in argument 'a'
>>> contains
>>> ?subroutine sub(a)
>>> ? real, external :: a
>>> ? print *, a(0.4)
>>> ?end subroutine sub
>>> end
>>>
>> Hm, it might be valid, but I think it still would be useful in such a
>> case to at least give a warning. Does none of the other compilers do?
>>
> No - the question is also what kind of warning do you want? There is
> simply a lack of information but that is a general problem with
> "external" - it can denote a function or a subroutine and before you use
> it, you don't know what it is. Explicit interfaces are much nicer, however.

Yeah, sure. Your main program has a lack of information regarding the
interface of 'func'. But here the compiler has additional information,
since the declaration of 'func' is in the same file.
So, a warning about differing interfaces might make sense. OTOH, the
programmer might chose *deliberately* to give an implicit interface to
'func' in the main program, which of course is valid with respect to
the Fortran standard (but you can do dangerous things this way). So
... I don't know. In any case the error should not be there (even if
one can argue about a warning), so this deserves a PR (have you
already opened one?).

Cheers,
Janus


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]