Am 09.07.25 um 08:50 schrieb Andre Vehreschild:
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).

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.

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.

NAG:

Runtime Error: array_constructor_1.f90, line 12: ALLOCATABLE LIST is not currently allocated
Program terminated by fatal error
Aborted


Regards,
        Andre

On Tue, 8 Jul 2025 22:17:23 +0200
Harald Anlauf <anl...@gmx.de> wrote:

Am 05.07.25 um 14:55 schrieb Mikael Morin:
Hello Andre,

I get a regression on this testcase with a patch that is otherwise
regression-free.
I think the testcase is invalid.
It does:
     type(container), allocatable :: list(:)

     list = [list, new_elem(5)]

so it's using the variable 'list' unallocated.
The original testcase in the PR had an extra zero-sized allocate
statement before the assignment.
I think it's the only missing bit.

Mikael,

I believe you are right: the testcase is technically invalid
without an

    allocate(list(0))

as in the original testcase in the PR.

A corresponding fix is approved.

Thanks,
Harald




Reply via email to