Skip to content
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

compiler crash multiplying zero vector #13058

Closed
Pyrolistical opened this issue Oct 3, 2022 · 5 comments · Fixed by #13074
Closed

compiler crash multiplying zero vector #13058

Pyrolistical opened this issue Oct 3, 2022 · 5 comments · Fixed by #13074
Assignees
Labels
bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@Pyrolistical
Copy link
Contributor

Pyrolistical commented Oct 3, 2022

Zig Version

0.10.0-dev.4217+9d8cdb855

Steps to Reproduce

  1. zig build-exe the following test.zig
pub fn main() !u8 {
    const v: @Vector(2, u8) = .{ 0, 0 };
    const v2 = v * v;

    return v2[0];
}

Expected Behavior

Builds exe

Actual Behavior

Crashes

$ zig build-exe test.zig
zsh: illegal hardware instruction  zig build-exe test.zig

Reproduced on x86_64-macos.12.6 if that matters.

@Pyrolistical Pyrolistical added the bug Observed behavior contradicts documented or intended behavior label Oct 3, 2022
@Pyrolistical Pyrolistical changed the title compiler crash compiler crash multiplying zero vector Oct 3, 2022
@topolarity topolarity self-assigned this Oct 3, 2022
@Pyrolistical
Copy link
Contributor Author

I ran into this when using https://github.com/michal-z/zig-gamedev/blob/main/libs/zmath/src/zmath.zig#L1447

The workaround for zig-gamedev is to use @mulAdd(T, v0, v1, v2) instead.

@topolarity
Copy link
Contributor

Hmm, I hit a crash if that is evaluated at comptime, but if v is var, then the program runs fine.

Were you calling mulAdd at comptime?

@Pyrolistical
Copy link
Contributor Author

Yes I was calling mulAdd at comptime.

@topolarity
Copy link
Contributor

Great, sounds like the same bug - I'll roll this together with some other small fixes tomorrow.

topolarity pushed a commit to topolarity/zig that referenced this issue Oct 5, 2022
topolarity added a commit to topolarity/zig that referenced this issue Oct 5, 2022
topolarity added a commit to topolarity/zig that referenced this issue Oct 5, 2022
topolarity added a commit to topolarity/zig that referenced this issue Oct 5, 2022
xxxbxxx pushed a commit to xxxbxxx/zig that referenced this issue Oct 9, 2022
topolarity added a commit to topolarity/zig that referenced this issue Oct 12, 2022
topolarity added a commit to topolarity/zig that referenced this issue Oct 13, 2022
@andrewrk andrewrk added this to the 0.10.1 milestone Oct 14, 2022
topolarity added a commit to topolarity/zig that referenced this issue Oct 19, 2022
topolarity added a commit to topolarity/zig that referenced this issue Oct 20, 2022
topolarity added a commit to topolarity/zig that referenced this issue Nov 1, 2022
topolarity added a commit to topolarity/zig that referenced this issue Nov 1, 2022
topolarity added a commit to topolarity/zig that referenced this issue Nov 1, 2022
topolarity added a commit to topolarity/zig that referenced this issue Nov 2, 2022
topolarity added a commit to topolarity/zig that referenced this issue Nov 10, 2022
@Pyrolistical
Copy link
Contributor Author

Can confirm fixed for my use-case. Thank you

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants