[J3] ac-implied-do + const-expr — question on expansion of such arrays

Malcolm Cohen malcolm at nag-j.co.jp
Wed Oct 14 21:11:15 EDT 2020

Yes it is a constant expression.


It is actually very clear, as item (12) it “what can go into a constant expression” is

   “an ac-do-variable within an array constructor where each scalar-int-expr of the corresponding ac8

implied-do-control is a constant expression”




..............Malcolm Cohen, NAG Oxford/Tokyo.


From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Tobias Burnus via J3
Sent: Thursday, October 15, 2020 5:53 AM
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Cc: Tobias Burnus <burnus at net-b.de>
Subject: [J3] ac-implied-do + const-expr — question on expansion of such arrays



the following issue came up – and it was unclear whether
"kind=i" is a "constant expression" or not when used as

In terms of compilers, one accepts it and two reject it.

If one first checks the expression itself, then "i" is
an ac-do-variable not not really constant for kind=i,
not fulfilling the constraint for kind=; while the int(i)
part is fine for 'int' (not constant but also not required).
If after this checking, the array is expanded, everything
else becomes known and simplifies to an array of numbers.

However, if the array is first expanded and then the values
are checked for constness, kind=n1 and kind=n2 are fine.

What's the proper interpretation?

use iso_fortran_env
integer, parameter :: n1 = minval(integer_kinds)
integer, parameter :: n2 = maxval(integer_kinds)
integer, parameter :: A(*) = [integer :: (int(A=i, kind=i), i=n1,n2,n2-n1)]
print *, A



The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. Please see our Privacy Notice <https://www.nag.co.uk/content/privacy-notice>  for information on how we process personal data and for details of how to stop or limit communications from us.

This e-mail has been scanned for all viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20201015/723aa293/attachment.htm>

More information about the J3 mailing list