hashlink icon indicating copy to clipboard operation
hashlink copied to clipboard

nested hl.NativeArray inconsistent behaviour for nulls

Open seanpringle opened this issue 5 years ago • 0 comments

Ubuntu 20.04 Haxe 4.1.1 hashlink: 1.11

When testing nested hl.NativeArray there is inconsistent behaviour when checking for nulls in conditional expressions, breaking both JIT and HL/C:

class Main {
  static var stuff : hl.NativeArray<hl.NativeArray<Int>>;

  public static function main() {
    stuff = new hl.NativeArray<hl.NativeArray<Int>>(10);
    stuff[5] = new hl.NativeArray<Int>(10);

    var i = 0;

    #if weirdness

    while (i < stuff.length && stuff[i] == null) {
      i++;
    }

    #else

    while (i < stuff.length) {
      if (stuff[i] != null) break;
      i++;
    }

    #end

    trace(i);
  }
}

Broken JIT:

$ haxe -main Main -hl test.hl -D weirdness
$ hl test.hl
JIT ERROR 12 (jit.c line 1856)

Expected JIT:

$ haxe -main Main -hl test.hl
$ hl test.hl
Main.hx:24: 5

Broken HL/C:

$ haxe -main Main -hl out/main.c -D weirdness
Error: Don't know how to compare array and array (hlc)

Expected HL/C:

$ haxe -main Main -hl out/main.c
Code generated in out/main.c automatic native compilation not yet implemented
$ cc -O1 -g -Wall -o test -std=c11 -Iout out/main.c
$ ./test
Main.hx:24: 5

seanpringle avatar Jun 18 '20 04:06 seanpringle