zig
zig copied to clipboard
`@addWithOverflow` with vectors doesn't work when they are from functions arguments
Zig Version
0.10.0-dev.4418+99c3578f6
Steps to Reproduce
To illustrate something like this:
const V = @Vector(2, u8);
fn addVec(_: V, _: V) @Vector(2, bool) {
var result: V = undefined;
return @addWithOverflow(V, V{ 2, 4 }, V { 6, 7 }, &result);
}
works fine, while the following:
const V = @Vector(2, u8);
fn addVec2(x: V, y: V) @Vector(2, bool) {
var result: V = undefined;
return @addWithOverflow(V, x, y, &result);
}
behaves very oddly
Expected Behavior
For it to compile normally
Actual Behavior
There is this following message:
error: expected type 'bool', found 'u1'
return @addWithOverflow(V, x, y, &result);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following code (the equality test specifically):
fn addVec3(x: V, y: V) bool {
var result: V = undefined;
return @reduce(.Or, @addWithOverflow(V, x, y, &result)) == 1;
}
crashes the compiler with illegal hardware instruction.