[J3] Can a procedure pointer have character(*) result type?

Brad Richardson everythingfunctional at protonmail.com
Tue Nov 29 22:18:06 UTC 2022


It's fine with the simpler example and performs as expected. I'll note that I think it's still not standards conforming, because you've basically lied about the interface to the external procedure, it just happens to be in a way that "works".

Ufortunately, the change you suggested to the abstract interface does not get around the ICE.

Regards,
Brad

On Tue, 2022-11-29 at 17:08 -0500, Vipul Parekh wrote:

> On Tue, Nov 29, 2022 at 4:46 PM Vipul Parekh <parekhvs at gmail.com> wrote:
>
>> ..
>> abstract interface
>> function Ifoo(arg) result(foo)
>> character(4) :: foo, arg
>> end function
>> end interface
>
> Thanks Brad for trying that out, ICEs really hurt when trying things out with compilers!
>
> This probably makes no difference to the ICE but I did mean the abstract interface to be
> abstract interface function Ifoo(arg) result(foo)
> character(*) :: arg
> character(4) :: foo
> end function
> end interface
>
> Re: "since the interface of proc no longer matches it is not legal", both Intel Fortran and gfortran don't complain about the following and give 'abcd' as the output. It will be interesting what NAG says about this case where the middleman `sub` is taken out!
> character(len=4), external :: foo
>
> abstract interface
> function Ifoo(arg) result(foo)
> character(len=*) :: arg
> character(len=4) :: foo
> end function
> end interface
> procedure(Ifoo), pointer :: proc
> proc => foo
> print *, proc("ab")
> end
>
> ! File foo.f90
> function foo(arg)
> character(len=*) :: foo, arg
> foo = arg // "cd"
> end function
>
> Regards,
> Vipul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20221129/e5b2b9d7/attachment.htm>


More information about the J3 mailing list