chapel icon indicating copy to clipboard operation
chapel copied to clipboard

[Bug]: Ignoring the return value of a type function results in a compiler segfault

Open jabraham17 opened this issue 9 months ago • 0 comments

Summary of Problem

Description: Ignoring the return value of a type function with a user defined generic type causes a compiler segfault. Making the type concrete or capturing the return value (type x = ...) restores correct behavior.

Is this a blocking issue with no known work-arounds? The workaround is to just use a unused return value like type x = ...

Steps to Reproduce

Source Code:

record R1 { }
record R2 { type t; }
record R3 { type t = int; }

proc bar(type t) type {
  compilerWarning(t:string);
  return t;
}

bar(int);

bar(R1);

bar(R2); // segfaults at compile-time
bar(R2(?)); // segfaults at compile-time
bar(R2(int)); 
bar(R3); // segfaults at compile-time
bar(R3(?)); // segfaults at compile-time
bar(R3(real));

type x = bar(R2); // this is fine

Compile command: chpl foo.chpl

Associated Future Test: test/functions/generic/type-func-return-generic.chpl

Configuration Information

  • Output of chpl --version: chpl version 2.1.0 pre-release (6eb9035242)
  • Output of $CHPL_HOME/util/printchplenv --anonymize:
CHPL_TARGET_PLATFORM: darwin
CHPL_TARGET_COMPILER: llvm
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: none
CHPL_MEM: jemalloc *
CHPL_ATOMICS: cstdlib
CHPL_GMP: system *
CHPL_HWLOC: bundled *
CHPL_RE2: bundled *
CHPL_LLVM: system *
CHPL_AUX_FILESYS: none
  • Back-end compiler and version, e.g. gcc --version or clang --version: Homebrew clang version 17.0.6

jabraham17 avatar May 14 '24 16:05 jabraham17