[J3] lbound / ubound undefined behaviour?

Robert Corbett rpcorbett at att.net
Thu Jun 27 16:56:07 UTC 2024


The behavior is well-defined.

References herein are to J3/10-007r1 (Fortran 2008).  Subclause 7.2.1.3 paragraph 3 states the array is allocated with

 o if /expr/ is an array, the shape of the /expr/ with each lower bound equal to the corresponding element of LBOUND(/expr/).

Subclause 13.7.90 (LBOUND) says that in this case, the lower bounds have the value 1.  Therefore, the result is well-defined and is as described by A.

Robert Corbett

> On Jun 27, 2024, at 8:46 AM, Nathan Sircombe via J3 <j3 at mailman.j3-fortran.org> wrote:
> 
> 
> Hi,
>  
> I’ve got a question from one of the engineers in the compiler team here – I’d appreciate the J3 list’s opinion (actually some of the list are on the original fortran-lang thread).
>  
> The problem was initially discussed here: https://fortran-lang.discourse.group/t/an-interesting-difference-between-compilers/7131
> The initial conclusion seems to be that compilers from group "B” have the wrong end of the stick. But a separate discussion on the Flang github reached a different conclusion: https://github.com/flang-compiler/flang/issues/1435. Claiming that we are facing undefined behaviour and various compilers handle this situation differently.
> So, is it actually undefined behaviour and the compilers have liberty in handling it their own way? or it is clearly defined what the compilers should do?
>  
> Cheers,
> Nathan.
> IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20240627/72146acd/attachment.htm>


More information about the J3 mailing list