Passing a class instance to an explicit-ref formal in an overridden method causes a type mismatch in the back-end C compiler.
--local
it compiles fine.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
chpl --version
:chpl Version 1.16.0 pre-release (64add955ac)
$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
gcc --version
or clang --version
:gcc (GCC) 7.1.1 20170621
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!