New Issue: [Bug]: C Backend error when passing nil to const ref

28675, "jabraham17", "[Bug]: C Backend error when passing nil to const ref", "2026-04-13T18:50:17Z"

The following program fails to compile with the C backend

proc foo(const ref bias,OC) {
  for o in 0..<OC {
    var val = if bias.type!=nil.type then bias[o] else 0.0:real(32);
  }
}
proc main() {
  const OC = 5;
  foo(nil,OC);
}
In file included from gen/_main.c:92:
gen/bug.c:34:12: error: cannot take the address of an rvalue of type 'int'
   34 |   foo_chpl(&nil, INT64(5));
      >            ^~~~
1 error generated.
make: *** [gen/_main.o] Error 1
error: compiling generated source

This code compiles fine with the LLVM backend

printchplenv

CHPL_HOME: /opt/homebrew/Cellar/chapel2.9.0/2.9.0/libexec
CHPL_RUNTIME_LIB: /opt/homebrew/Cellar/chapel2.9.0/2.9.0/libexec/lib
CHPL_RUNTIME_INCL: /opt/homebrew/Cellar/chapel2.9.0/2.9.0/libexec/runtime/include
CHPL_THIRD_PARTY: /opt/homebrew/Cellar/chapel2.9.0/2.9.0/libexec/third-party

machine info: Darwin HPE-D2RLK75V43 25.3.0 Darwin Kernel Version 25.3.0: Wed Jan 28 20:54:46 PST 2026; root:xnu-12377.91.3~2/RELEASE_ARM64_T6000 arm64
CHPL_HOME: /opt/homebrew/Cellar/chapel2.9.0/2.9.0/libexec *
script location: /opt/homebrew/Cellar/chapel2.9.0/2.9.0/libexec/util/chplenv
CHPL_HOST_PLATFORM: darwin
CHPL_HOST_COMPILER: clang
  CHPL_HOST_CC: clang
  CHPL_HOST_CXX: clang++
CHPL_HOST_ARCH: arm64
CHPL_TARGET_PLATFORM: darwin
CHPL_TARGET_COMPILER: clang *
  CHPL_TARGET_CC: clang
  CHPL_TARGET_CXX: clang++
  CHPL_TARGET_LD: clang++
CHPL_TARGET_ARCH: arm64
CHPL_TARGET_CPU: native +
CHPL_LOCALE_MODEL: flat
CHPL_COMM: none
CHPL_TASKS: qthreads
CHPL_LAUNCHER: none
CHPL_TIMERS: generic
CHPL_UNWIND: system
CHPL_HOST_MEM: cstdlib
CHPL_TARGET_MEM: jemalloc +
  CHPL_TARGET_JEMALLOC: system +
CHPL_ATOMICS: cstdlib
CHPL_GMP: system +
CHPL_HWLOC: system +
CHPL_RE2: bundled +
CHPL_LLVM: system +
  CHPL_LLVM_SUPPORT: system
  CHPL_LLVM_CONFIG: /opt/homebrew/opt/llvm@21/bin/llvm-config +
  CHPL_LLVM_VERSION: 21
CHPL_AUX_FILESYS: none
CHPL_LIB_PIC: none
CHPL_SANITIZE: none
CHPL_SANITIZE_EXE: none