[J3] [EXTERNAL] [BULK] Is this conforming?

Clune, Thomas L. (GSFC-6101) thomas.l.clune at nasa.gov
Wed Jun 4 13:18:34 UTC 2025


Thanks Bob,

I’ve got to start forcing myself not to respond to these types of questions while listening to another meeting.   With the procedure named “i1”, my eyes just saw that as an integer inside the expression, and completely missed the subtlety of Daniel’s question.  (Apologies to Daniel.)

Cheers,


  *   Tom

[signature_1452349390]<https://www.nasa.gov/>

Thomas Clune
Lead, Software Infrastructure
Global Modeling and Assimilation Office
NASA Goddard Space Flight Center
MS 610.1
8800 Greenbelt RD, Greenbelt, MD 20771
Thomas.L.Clune at nasa.gov<mailto:Thomas.L.Clune at nasa.gov>


From: J3 <j3-bounces at mailman.j3-fortran.org> on behalf of Robert Corbett via J3 <j3 at mailman.j3-fortran.org>
Date: Wednesday, June 4, 2025 at 1:02 AM
To: Clune, Thomas L. (GSFC-6101) via J3 <j3 at mailman.j3-fortran.org>
Cc: Robert Corbett <rpcorbett at att.net>
Subject: Re: [J3] [EXTERNAL] [BULK] Is this conforming?
CAUTION: This email originated from outside of NASA.  Please take care when clicking links or opening attachments.  Use the "Report Message" button to report suspicious messages to the NASA SOC.


Tom's reply is correct.

To amplify Tom's response, paragraph 2
of subclause 10.1.4 states

      if a function reference causes
      definition or undefinition of
      an actual argument of the
      function, that argument or any
      associated entities shall not
      appear elsewhere in the same
      statement.

The actual argument i1 appears three
times in the assignment statement.

If the two references of the function
newLB are replaced by scalar integer
variables set to the values of the
function references in separate
assignment statements preceding the
assignment statement shown in your
example and the segfaults are still
signaled, there is a good chance that
the implementation is not conformant.

Bob Corbett
On Tuesday, June 3, 2025 at 12:07:58 PM PDT, Clune, Thomas L. (GSFC-6101) via J3 <j3 at mailman.j3-fortran.org> wrote:



Hi Daniel,



Your LHS is a slice of i1, but i1 has not been allocated yet …



·         Tom



[signature_2763519993]<https://www.nasa.gov/>



Thomas Clune

Lead, Software Infrastructure

Global Modeling and Assimilation Office

NASA Goddard Space Flight Center

MS 610.1

8800 Greenbelt RD, Greenbelt, MD 20771

Thomas.L.Clune at nasa.gov<mailto:Thomas.L.Clune at nasa.gov>





From: J3 <j3-bounces at mailman.j3-fortran.org> on behalf of Daniel Chen via J3 <j3 at mailman.j3-fortran.org>
Date: Tuesday, June 3, 2025 at 3:02 PM
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Cc: Daniel Chen <cdchen at ca.ibm.com>
Subject: [EXTERNAL] [BULK] [J3] Is this conforming?

CAUTION: This email originated from outside of NASA.  Please take care when clicking links or opening attachments.  Use the "Report Message" button to report suspicious messages to the NASA SOC.



Hello,

Is the following code conforming?

```
module m

    contains



    integer function newLB (i1)

        integer, allocatable :: i1(:)



        allocatable newLB



        i1 = [(i, i=1,5)]



        newLB = ubound(i1,1) -2

    end function

end module



use m

    integer, allocatable :: i1(:)



    i1(newLB(i1): newLB(i1)+2) = [1,2,3]

end
```

It seems OK to me as the standard requires the evaluation of all the `expr` within the `variable` to be done before any part of the `variable` is defined. But most of the compilers that I have access to segfault on this.

Thanks,
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20250604/411872c8/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 25179 bytes
Desc: image001.png
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20250604/411872c8/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 275 bytes
Desc: image002.png
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20250604/411872c8/attachment-0001.png>


More information about the J3 mailing list