jfecher / ante

A safe, easy systems language
http://antelang.org
MIT License
1.89k stars 79 forks source link

Malloc Panics with -O0 or crane_lift #174

Closed eldesh closed 8 months ago

eldesh commented 8 months ago

In e38231f, compiling the following code at -O0:

size: Usz = 1
main () =
  _ = malloc size

main ()

Results in the compiler panicking and outputting the following error:

$ ante  -b bug.an
thread 'main' panicked at src/cranelift_backend/context.rs:197:13:
- inst0 (v1 = call fn0(v0)): arg 0 (v0) has type i8, expected i64

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

No errors occur with -O3.

jfecher commented 8 months ago

This is a duplicate of https://github.com/jfecher/ante/issues/142. The code works as expected when using malloc 1 directly.