Skip to content

@addWithOverflow with vectors doesn't work when they are from functions arguments #13201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DiskPoppy opened this issue Oct 16, 2022 · 2 comments
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@DiskPoppy
Copy link

DiskPoppy commented Oct 16, 2022

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.

@DiskPoppy DiskPoppy added the bug Observed behavior contradicts documented or intended behavior label Oct 16, 2022
@Vexu Vexu added the frontend Tokenization, parsing, AstGen, Sema, and Liveness. label Oct 17, 2022
@Vexu Vexu added this to the 0.10.1 milestone Oct 17, 2022
Vexu added a commit to Vexu/zig that referenced this issue Nov 23, 2022
It should return a a vector of bools for compatibility with scalar
operands and stage1 until ziglang#10248 can be implemented.

Closes ziglang#13201
Vexu added a commit to Vexu/zig that referenced this issue Nov 25, 2022
It should return a a vector of bools for compatibility with scalar
operands and stage1 until ziglang#10248 can be implemented.

Closes ziglang#13201
@Vexu Vexu closed this as completed in 72fa8d4 Nov 26, 2022
@andrewrk
Copy link
Member

not solved yet, there is still:

continue; //TODO: https://github.com/ziglang/zig/issues/13201

@andrewrk andrewrk reopened this Dec 19, 2022
@Vexu
Copy link
Member

Vexu commented Dec 19, 2022

That looks completely unrelated? Maybe it's linking the wrong issue by accident?

Vexu added a commit to Vexu/zig that referenced this issue Dec 19, 2022
@Vexu Vexu closed this as completed in 2926d95 Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

No branches or pull requests

3 participants