Zig Version
0.9.0-dev.1675+3d528161c
Steps to Reproduce
To reproduce, feed this to zig translate-c:
#include <stdio.h>
#include <limits.h>
int sign(int v) {
return -(v < 0);
}
void main() {
int res = sign(-5);
printf("Sign: %d\n", res);
}
Expected Behavior
I expected working C code for the sign function, maybe something like this:
pub export fn sign(arg_v: c_int) c_int {
var v = arg_v;
return -(@intCast(c_int, @boolToInt(v < @as(c_int, 0))));
}
Actual Behavior
zig translate-c currently generates this:
pub export fn sign(arg_v: c_int) c_int {
var v = arg_v;
return -(v < @as(c_int, 0));
}
which causes
`error: negation of type 'bool'`
when trying to compile the code.
Zig Version
0.9.0-dev.1675+3d528161c
Steps to Reproduce
To reproduce, feed this to
zig translate-c:Expected Behavior
I expected working C code for the sign function, maybe something like this:
Actual Behavior
zig translate-c currently generates this:
which causes
when trying to compile the code.