Chapel: Passing a class instance to an explicit-ref formal in an overridden method

Created on 10 Jul 2017  路  4Comments  路  Source: chapel-lang/chapel

Summary of Problem

Passing a class instance to an explicit-ref formal in an overridden method causes a type mismatch in the back-end C compiler.

  • This behavior occurs when the argument is a local instance or a field.
  • Only occurs with CHPL_COMM!=none. In other words, with --local it compiles fine.

Steps to Reproduce

Source Code:

class SuperPrinter {
  //for faulty behavior this formal must have an explicit ref intent
  proc print(ref data) {
    writeln("SuperPrinter: ", data.x);
  }
}

class SubPrinter : SuperPrinter {
  proc print(ref data) {
    writeln("Subprinter: ", data.x);
  }
}

class Foo { var x = 10; }

proc main() {
  var printer: SuperPrinter;
  printer = new SubPrinter();

  var data = new Foo();
  printer.print(data);
}

Compile command:
chpl foo.chpl

Configuration Information

  • Output of chpl --version:
chpl Version 1.16.0 pre-release (64add955ac)
  • Output of $CHPL_HOME/util/printchplenv --anonymize:
CHPL_TARGET_PLATFORM: linux64
CHPL_TARGET_COMPILER: gnu
CHPL_TARGET_ARCH: unknown
CHPL_LOCALE_MODEL: flat
CHPL_COMM: gasnet *
  CHPL_COMM_SUBSTRATE: udp
  CHPL_GASNET_SEGMENT: everything
CHPL_TASKS: qthreads
CHPL_LAUNCHER: amudprun
CHPL_TIMERS: generic
CHPL_UNWIND: none
CHPL_MEM: jemalloc
CHPL_MAKE: make
CHPL_ATOMICS: intrinsics
  CHPL_NETWORK_ATOMICS: none
CHPL_GMP: none
CHPL_HWLOC: hwloc
CHPL_REGEXP: re2
CHPL_WIDE_POINTERS: struct
CHPL_AUX_FILESYS: none
  • Back-end compiler and version, e.g. gcc --version or clang --version:
gcc (GCC) 7.1.1 20170621
Compiler Bug

All 4 comments

Something encountered by @LouisJenkinsCS in a much more complicated code. Hopefully, this captures the root cause in its entirety.

This is almost certainly a bug in the insertWideReferences pass. I will investigate.

Well, this was a silly bug. I have a fix ready in #6647 , which includes a new test to keep us honest going forward.

Thanks @benharsh!

Was this page helpful?
0 / 5 - 0 ratings