OffTarget

Observed issues › clang-c-linear-directive-name-hang

Appears to behave incorrectlyCompiler hangs · C · OpenMP · Open

Linear(x: for, step(2)) sends the front end into an endless loop after "too many errors"

Legality: independently confirmed. 2 independent readings find the program legal and the result required. How this is checked

Affected variants

CompilerMI300A gfx942
unified memory (XNACK 1)
MI300A gfx942
copy (XNACK 0)
MI250X gfx90a
copy (XNACK 0)
MI300X gfx942
copy (XNACK 0)
MI350X gfx950
copy (XNACK 0)
A100 sm_80
separate memory
A100 sm_80
managed memory
AFAR 24.3.0behaves incorrectlybehaves incorrectlyunknown
not run
behaves incorrectlybehaves incorrectlyn/an/a
CCE 19.0.0behaves incorrectlybehaves incorrectlyunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 20.0.2behaves incorrectlybehaves incorrectlyunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.3behaves incorrectlybehaves incorrectlyunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.4behaves incorrectlybehaves incorrectlyunknown
not run
unknown
not run
unknown
not run
n/an/a
NVHPC 25.11n/an/an/an/an/acorrectcorrect
NVHPC 26.9n/an/an/an/an/acorrectcorrect
GCC 16.2.0fails another wayfails another wayfails another wayfails another wayfails another wayfails another wayn/a

"behaves incorrectly" / "not supported": this issue, confirmed in up to four environments (another build directory, another node, a repeat). "fails another way": a different failure, not counted as this issue. "unknown": not run there, or the runs disagree.

Messages

ResultCompiler and GPUMessage
behaves incorrectlyAFAR 24.3.0, MI300A unified
AFAR 24.3.0, MI300A copy
AFAR 24.3.0, MI300X
AFAR 24.3.0, MI350X
CCE 19.0.0, MI300A unified
CCE 19.0.0, MI300A copy
CCE 20.0.2, MI300A unified
CCE 20.0.2, MI300A copy
CCE 21.0.3, MI300A unified
CCE 21.0.3, MI300A copy
CCE 21.0.4, MI300A unified
CCE 21.0.4, MI300A copy
show
clang-c-linear-directive-name-hang.c:3:38: error: expected expression
    3 |   #pragma omp parallel for linear(x: for, step(2))
      |                                      ^
clang-c-linear-directive-name-hang.c:3:38: error: expected expression
clang-c-linear-directive-name-hang.c:3:38: error: expected expression
clang-c-linear-directive-name-hang.c:3:38: error: expected expression
clang-c-linear-directive-name-hang.c:3:38: error: expected expression
clang-c-linear-directive-name-hang.c:3:38: error: expected expression
fails another wayGCC 16.2.0, MI300A unified
GCC 16.2.0, MI300A copy
GCC 16.2.0, MI250X
GCC 16.2.0, MI300X
GCC 16.2.0, MI350X
GCC 16.2.0, A100 separate
show
clang-c-linear-directive-name-hang.c: In function ‘main’:
clang-c-linear-directive-name-hang.c:3:38: error: expected expression before ‘for’
    3 |   #pragma omp parallel for linear(x: for, step(2))
      |                                      ^~~
clang-c-linear-directive-name-hang.c:3:34: error: ‘linear’ clause step expression must be integral
    3 |   #pragma omp parallel for linear(x: for, step(2))
      |                                  ^

Reproduce

AFAR 24.3.0, MI300A unified

$AFAR/bin/amdclang -fopenmp --offload-arch=gfx942 -fopenmp-version=60 -fopenmp-version=60 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro

CCE 19.0.0, MI300A unified

module load cce/19.0.0 craype-accel-amd-gfx942 rocm/6.4.3
module unload cray-mpich
craycc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx942 -fopenmp-version=60 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro

CCE 20.0.2, MI300A unified

module load cce/20.0.2 craype-accel-amd-gfx942 rocm/6.4.3
module unload cray-mpich
craycc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx942 -fopenmp-version=60 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro

CCE 21.0.3, MI300A unified

module load cce/21.0.3 craype-accel-amd-gfx942 rocm/7.2.0
module unload cray-mpich
craycc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx942 -fopenmp-version=60 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro

CCE 21.0.4, MI300A unified

module load cce/21.0.4 craype-accel-amd-gfx942 rocm/7.2.0
module unload cray-mpich
craycc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx942 -fopenmp-version=60 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro

NVHPC 25.11, A100 separate (runs correctly)

export LD_LIBRARY_PATH=$NVHPC_25_11/compilers/lib
nvc -mp=gpu -gpu=cc80 -gpu=mem:separate -O2 repro.c -o repro
OMP_TARGET_OFFLOAD=mandatory ./repro
Program (24 lines)
/* Finding (C): a directive-name modifier in a linear clause sends
   the clang front end into an endless loop.

   Legal OpenMP 6.0 C: linear(x: for, step(2)) names the directive the
   clause applies to (6.0 §5.4, p.174: "The directive-name-modifier is a
   universal modifier that can be used on any clause"; linear, 6.0
   §7.5.6, p.232). Expected: compiles
   (or, for a compiler without the 6.0 modifier, one diagnostic).

   Observed (2026-10-19): AFAR amdclang 24.0.0git and CCE craycc 19.0.0
   (the omp60-c-clause-linear-directive_name program: also 20.0.2 and
   21.0.3) print "error: expected expression" at the `for` twenty times,
   then "fatal error: too many errors emitted, stopping now", and do not
   exit: killed after 40 s with -fsyntax-only (the matrix: compile
   timeout on all four toolchains). Without `for,` it compiles at once.

   amdclang -fopenmp -fopenmp-version=60 -fsyntax-only
   craycc -fopenmp -fopenmp-version=60 -fsyntax-only */
int main(void) {
  int x = 0, b[8];
  #pragma omp parallel for linear(x: for, step(2))
  for (int i = 0; i < 8; i++) { b[i] = x; x += 2; }
  return b[1];
}

Source in the repository

Something to add? Dispute its legality · Report it fixed in a newer release · Report a mistake on this page

Expected and observed

Observed where it behaves incorrectly

clang-c-linear-directive-name-hang.c:3:38: error: expected expression
    3 |   #pragma omp parallel for linear(x: for, step(2))
      |                                      ^
clang-c-linear-directive-name-hang.c:3:38: error: expected expression
clang-c-linear-directive-name-hang.c:3:38: error: expected expression
clang-c-linear-directive-name-hang.c:3:38: error: expected expression
clang-c-linear-directive-name-hang.c:3:38: error: expected expression
clang-c-linear-directive-name-hang.c:3:38: error: expected expression

What the specification requires

The specification text this program relies on and the compiler is expected to support.

OpenMP 6.0 §5.4 p.174

The directive-name-modifier is a universal modifier that can be used on any clause

OpenMP 6.0 §7.5.6 p.232

Evidence

Same compiler, one change

  • linear(x: step(2)) without the directive-name modifier: AFAR 24.3.0: correct; CCE 19.0.0: correct; CCE 20.0.2: correct; CCE 21.0.3: correct; CCE 21.0.4: correct
    Control program
    int main(void) {
      int x = 0, b[8];
      #pragma omp parallel for linear(x: step(2))
      for (int i = 0; i < 8; i++) { b[i] = x; x += 2; }
      return b[1];
    }
    

Other compilers run it correctly

NVHPC 25.11, NVHPC 26.9