Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Mediocrity finds safety in standardization. -- Frederick Crane


devel / comp.lang.fortran / Procedure pointer initialization

SubjectAuthor
* Procedure pointer initializationJames Van Buskirk
`- Re: Procedure pointer initializationJRR

1
Procedure pointer initialization

<t6cq81$gv1$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2281&group=comp.lang.fortran#2281

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: not_valid@comcast.net (James Van Buskirk)
Newsgroups: comp.lang.fortran
Subject: Procedure pointer initialization
Date: Sun, 22 May 2022 01:54:29 -0600
Organization: A noiseless patient Spider
Lines: 1
Message-ID: <t6cq81$gv1$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain;
format=flowed;
charset="iso-8859-1";
reply-type=original
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 22 May 2022 07:54:41 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="5a78bb2bdd79828c10bb9ac87138d5d0";
logging-data="17377"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/lLAZMkPhMakW2Y3b7qKMuwfdFkrVq3cE="
Cancel-Lock: sha1:UNfmQ2pbbW6ktmSGE/+irq9rALs=
X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331
X-Newsreader: Microsoft Windows Live Mail 16.4.3528.331
Importance: Normal
X-Priority: 3
X-MSMail-Priority: Normal
 by: James Van Buskirk - Sun, 22 May 2022 07:54 UTC

I think my example is a syntactically correct instance of procedure
pointer initialization but both gfortran and an old version of ifort
error out on it:

module funcs
implicit none
interface
subroutine a() bind(C,name='a1')
implicit none
end subroutine a
subroutine b() bind(C,name='a2')
implicit none
end subroutine b
end interface
end module funcs

program start
use funcs
implicit none
type has_fun
procedure(a), pointer, nopass :: fun
end type has_fun
type(has_fun) :: lots(2) = [has_fun(a),has_fun(b)]
procedure(a), pointer :: stuff => b
end program start

subroutine c() bind(C,name='a1')
implicit none
end subroutine c

subroutine d() bind(C,name='a2')
implicit none
end subroutine d

Re: Procedure pointer initialization

<t6fi19$11nu$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2287&group=comp.lang.fortran#2287

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!aioe.org!WtQcAnsyEb/6J9EbbIWP4A.user.46.165.242.91.POSTED!not-for-mail
From: juergen.reuter@invalid.com (JRR)
Newsgroups: comp.lang.fortran
Subject: Re: Procedure pointer initialization
Date: Mon, 23 May 2022 10:52:56 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t6fi19$11nu$1@gioia.aioe.org>
References: <t6cq81$gv1$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="34558"; posting-host="WtQcAnsyEb/6J9EbbIWP4A.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.9.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: JRR - Mon, 23 May 2022 08:52 UTC

Hi James,
indeed, the code looks standard-conforming to me. The problem is the
initialization of lots, using of array of objects built by structure
constructors. gfortran and ifort complain that they don't know what
a is, so they can't resolve the interfaces from module funcs, nagfor
compiles without complaints. If you use
type(has_fun), dimension(2) :: lots
[...]
lots = [has_fun(a), has_fun(b)]

gfortran compiles this as well, while ifort 2021.5.0 produces an ICE.
You should report this to gfortran and Intel.
Cheers,
JRR

Am 22.05.22 um 09:54 schrieb James Van Buskirk:
> I think my example is a syntactically correct instance of procedure
> pointer initialization but both gfortran and an old version of ifort
> error out on it:
>
> module funcs
>   implicit none
>   interface
>      subroutine a() bind(C,name='a1')
>         implicit none
>      end subroutine a
>      subroutine b() bind(C,name='a2')
>         implicit none
>      end subroutine b
>   end interface
> end module funcs
>
> program start
>   use funcs
>   implicit none
>   type has_fun
>      procedure(a), pointer, nopass :: fun
>   end type has_fun
>   type(has_fun) :: lots(2) = [has_fun(a),has_fun(b)]
>   procedure(a), pointer :: stuff => b
> end program start
>
> subroutine c() bind(C,name='a1')
>   implicit none
> end subroutine c
>
> subroutine d() bind(C,name='a2')
>   implicit none
> end subroutine d
>

--
Juergen Reuter
Theoretical Particle Physics
Deutsches Elektronen-Synchrotron (DESY)
Hamburg, Germany

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor