Issue with array allocation in C++

ifx -fiopenmp corrupts whole-array assignment to CFI-allocated array

Minimal reproducer for an Intel oneAPI Fortran (ifx) bug observed in DAMASK
(GitHub - damask-multiphysics/DAMASK: Düsseldorf Advanced Material Simulation Kit (Read-only mirror) · GitHub). In discretization_grid.f90 the line

materialAt_global = materialAt_global + 1

corrupted the material-ID array when compiled with oneAPI, while the
array-section form materialAt_global(:) = materialAt_global(:) + 1 worked.

Pattern

  1. A BIND(C) subroutine declared as
    integer(C_INT), allocatable, intent(out) :: data(:) is called from Fortran.
  2. C allocates the array via CFI_allocate and fills it (fill.c).
  3. Fortran performs a whole-array assignment to the returned allocatable:
    a = a + 1.
  4. The whole unit is compiled with -fiopenmp.

With -fiopenmp, values in the LHS array are silently corrupted for arrays
above a certain size (seen from ~4000 elements up; the failure is not
monotonic in size — n=8000 passed in one run while n=4000 failed). Elements
are overwritten with garbage. Without -fiopenmp, or with the
array-section form, the result is correct.

Which (:) matters

Only the combination where both sides are whole-array triggers the bug;
(:) on either side alone is sufficient to avoid it:

Form mismatches at n=29760
a = a + 1 (both whole) 29712 BROKEN
a = a(:) + 1 (LHS whole) 0 OK
a(:) = a + 1 (RHS whole) 0 OK
a(:) = a(:) + 1 (both sect) 0 OK

Reproduce

source /path/to/oneapi/setvars.sh
make run              # BROKEN: whole-array assignment with -fiopenmp
make run-workaround   # OK:     array-section assignment
make run-noopenmp     # OK:     whole-array assignment without -fiopenmp
make run-small        # OK:     small array (n=1000)
make run-variants     # LHS/RHS section combination matrix (n=29760)

Environment

  • ifx 2026.1.0 (20260617), icx 2026.1.0 (20260617)
  • oneAPI HPC toolkit 2026.1, Linux x86_64
  • Trigger flag: -fiopenmp (any -O level reproduces)

Files

main.f90 (732 Bytes)
main_variants.f90 (1.2 KB)
main_workaround.f90 (735 Bytes)
fill.c.txt (555 Bytes) should be called fill.c
fill.c.txt (519 Bytes) should be called fill.c (updated version, closer to the original code)
Makefile.txt (1.7 KB) should be called Makefile

1 Like

Hi Martin,

did you file this with Intel or would you like some help getting it somewhere?

Cheers

1 Like

I’ve just posted it in the Intel forum: https://community.intel.com/t5/Intel-Fortran-Compiler/Issue-with-array-allocation-in-C-ISO-Fortran-binding-h/m-p/1755394#M179301

1 Like