[J3] Can a disassociated pointer invoke a type-bound procedure?

Daniel Chen cdchen at ca.ibm.com
Fri Jun 13 15:45:04 UTC 2025


Thanks Ivan.

Yeah, this is what I was looking for.

Daniel

From: J3 <j3-bounces at mailman.j3-fortran.org> on behalf of Pribec, Ivan via J3 <j3 at mailman.j3-fortran.org>
Date: Thursday, June 12, 2025 at 4:57 PM
To: j3 at mailman.j3-fortran.org <j3 at mailman.j3-fortran.org>
Cc: Pribec, Ivan <Ivan.Pribec at lrz.de>
Subject: Re: [J3] [EXTERNAL] Can a disassociated pointer invoke a type-bound procedure?
Hi Daniel, I think the paragraph you might be looking for is Section 15. 5. 1, paragraph 2: The data-ref in a procedure-designator shall not be an unallocated allocatable variable or a pointer that is not associated. (Thanks to Malcolm Cohen for

Hi Daniel,

I think the paragraph you might be looking for is

Section 15.5.1, paragraph 2:
The data-ref in a procedure-designator shall not be an unallocated allocatable variable or a pointer that is not associated.

(Thanks to Malcolm Cohen for pointing it out to me previously).

A related example with allocatable objects can be found here: https://github.com/klausler/fortran-wringer-tests/issues/12<https://github.com/klausler/fortran-wringer-tests/issues/12 >

Best regards,

Ivan Pribec

________________________________
From: J3 <j3-bounces at mailman.j3-fortran.org> on behalf of j3-request at mailman.j3-fortran.org <j3-request at mailman.j3-fortran.org>
Sent: Thursday, June 12, 2025 9:01 PM
To: j3 at mailman.j3-fortran.org
Subject: J3 Digest, Vol 88, Issue 22

Send J3 mailing list submissions to
        j3 at mailman.j3-fortran.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://mailman.j3-fortran.org/mailman/listinfo/j3<https://mailman.j3-fortran.org/mailman/listinfo/j3 >
or, via email, send a message with subject or body 'help' to
        j3-request at mailman.j3-fortran.org

You can reach the person managing the list at
        j3-owner at mailman.j3-fortran.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of J3 digest..."


Today's Topics:

   1. Can a disassociated pointer invoke a type-bound procedure?
      (Daniel Chen)
   2. Re: [EXTERNAL] Can a disassociated pointer invoke a
      type-bound procedure? (Reuben D. Budiardja)
   3. Re: [EXTERNAL] Can a disassociated pointer invoke a
      type-bound procedure? (Van Snyder)


----------------------------------------------------------------------

Message: 1
Date: Thu, 12 Jun 2025 16:37:32 +0000
From: Daniel Chen <cdchen at ca.ibm.com>
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Subject: [J3] Can a disassociated pointer invoke a type-bound
        procedure?
Message-ID:
        <SJ2PR15MB6443542800C3C1CE2B891644F874A at SJ2PR15MB6443.namprd15.prod.outlook.com>

Content-Type: text/plain; charset="windows-1252"

In the following code, pointer ?b1? is not associated with any target. Is it conforming for ?b1? to invoke the type-bound procedure of its type?

```
module m1
   type base
      integer :: id
   contains
      procedure, nopass :: type => basetype
   end type
contains
   integer function basetype()
      basetype = 1
   end function
end module

use m1
type(base), pointer :: b1 => null()
print*, b1%type()
end
```

Thanks,
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20250612/ae432c67/attachment-0001.htm<https://mailman.j3-fortran.org/pipermail/j3/attachments/20250612/ae432c67/attachment-0001.htm >>

------------------------------

Message: 2
Date: Thu, 12 Jun 2025 14:08:15 -0400
From: "Reuben D. Budiardja" <reubendb at ornl.gov>
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Subject: Re: [J3] [EXTERNAL] Can a disassociated pointer invoke a
        type-bound procedure?
Message-ID: <47788f4f-4df0-89fa-0e8a-7280aad502e8 at ornl.gov>
Content-Type: text/plain; charset="UTF-8"; format=flowed

Hi Daniel,

I think 8.5.12 para 2: "A data pointer shall not be referenced unless it
is pointer associated with a target object that is defined"
would make this illegal.

Best,
Reuben


On 6/12/25 12:37, Daniel Chen via J3 wrote:
> In the following code, pointer ?b1? is not associated with any target.
> Is it conforming for ?b1? to invoke the type-bound procedure of its
> type? ``` module m1 type base integer :: id contains procedure, nopass
> :: type => basetype end type
>
>
> In the following code, pointer ?b1? is not associated with any target.
> Is it conforming for ?b1? to invoke the type-bound procedure of its type?
>
> ```
> module m1
>
>  ?? type base
>
>  ????? integer :: id
>
>  ?? contains
>
>  ????? procedure, nopass :: type => basetype
>
>  ?? end type
>
> contains
>
>  ?? integer function basetype()
>
>  ????? basetype = 1
>
>  ?? end function
>
> end module
>
> use m1
>
> type(base), pointer :: b1 => null()
>
> print*, b1%type()
>
> end
> ```
>
> Thanks,
> Daniel
>


------------------------------

Message: 3
Date: Thu, 12 Jun 2025 12:01:26 -0700
From: Van Snyder <van.snyder at sbcglobal.net>
To: j3 at mailman.j3-fortran.org
Subject: Re: [J3] [EXTERNAL] Can a disassociated pointer invoke a
        type-bound procedure?
Message-ID:
        <3a39369b1c3d7f64c930d4c823e865034750b864.camel at sbcglobal.net>
Content-Type: text/plain; charset="utf-8"

On Thu, 2025-06-12 at 14:08 -0400, Reuben D. Budiardja via J3 wrote:
> Hi Daniel,
>
> I think 8.5.12 para 2: "A data pointer shall not be referenced unless
> it
> is pointer associated with a target object that is defined"
> would make this illegal.

Because the binding has "nopass" it's not obvious the data pointer is
being referenced.

>
> Best,
> Reuben
>
>
> On 6/12/25 12:37, Daniel Chen via J3 wrote:
> > In the following code, pointer ?b1? is not associated with any
> > target.
> > Is it conforming for ?b1? to invoke the type-bound procedure of its
> > type? ``` module m1 type base integer :: id contains procedure,
> > nopass
> > :: type => basetype end type
> >
> >
> > In the following code, pointer ?b1? is not associated with any
> > target.
> > Is it conforming for ?b1? to invoke the type-bound procedure of its
> > type?
> >
> > ```
> > module m1
> >
> > ??? type base
> >
> > ?????? integer :: id
> >
> > ??? contains
> >
> > ?????? procedure, nopass :: type => basetype
> >
> > ??? end type
> >
> > contains
> >
> > ??? integer function basetype()
> >
> > ?????? basetype = 1
> >
> > ??? end function
> >
> > end module
> >
> > use m1
> >
> > type(base), pointer :: b1 => null()
> >
> > print*, b1%type()
> >
> > end
> > ```
> >
> > Thanks,
> > Daniel
> >

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20250612/7b3faddd/attachment.htm<https://mailman.j3-fortran.org/pipermail/j3/attachments/20250612/7b3faddd/attachment.htm >>

End of J3 Digest, Vol 88, Issue 22
**********************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20250613/f8fe79b7/attachment.htm>


More information about the J3 mailing list