Le 09/07/2025 à 08:50, Andre Vehreschild a écrit :
HI Harald, hi Mikael,

why shall the testcase be invalid? The `list` is empty. Concatenating with it
is valid in Fortran like in most other programming languages. The mapping of an
empty list in gfortran is to have the array's data pointer set to NULL and the
ubound below the lbound. Current gfortran copes fine with this, so does Intel's
Fortran compiler and flang (all executables tested with valgrind).

The intent of the program is clear for a human, but for a compiler, the language makes them distinct: unallocated is not the same as empty.

In F2018 §7.8 Paragraph 8 it states: "An empty sequence forms a zero-sized
array", This is the closest it gets to an unallocated array, but it does not
exclude nor include it.

There is 9.2 and 9.3:
  The appearance of a data object designator in a context that requires
its value is termed a reference.
  A reference is permitted only if the variable is defined.

and 19.6.3 and 19.6.4:
  The following variables are initially defined:
   (...) (6 items where allocatable variables don't appear)
  Variables that are not initially defined are initially undefined.

Maybe someone with access to other fortran compilers can test this, too. But I
see all compilers available to me be fine with an unallocated array in the
array constructor. But I am doing to much wrong at the moment, so don't value
my words too much.

There are some language design aspects that I find strange or confusing myself when I encounter them from time to time, but we have to leave with them.

Reply via email to