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

Sema: emits incorrect safety check for integer vector division #22914

Open
jacobly0 opened this issue Feb 16, 2025 · 0 comments
Open

Sema: emits incorrect safety check for integer vector division #22914

jacobly0 opened this issue Feb 16, 2025 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. miscompilation The compiler reports success but produces semantically incorrect code.
Milestone

Comments

@jacobly0
Copy link
Member

jacobly0 commented Feb 16, 2025

var lhs: @Vector(2, i8) = .{ -128, 0 };
const rhs: @Vector(2, i8) = .{ 1, -1 };
pub fn main() void {
    _ = @divTrunc(lhs, rhs);
}
$ zig run repro.zig
thread 476777 panic: integer overflow
repro.zig:4:9: 0x103a524 in main (repro)
    _ = @divTrunc(lhs, rhs);
        ^
lib/std/start.zig:647:22: 0x1039f72 in posixCallMainAndExit (repro)
            root.main();
                     ^
lib/std/start.zig:271:5: 0x1039b4d in _start (repro)
    asm volatile (switch (native_arch) {
    ^
???:?:?: 0x0 in ??? (???)
Aborted (core dumped)

As an added bonus for fixing this bug, you can delete the lines in test/behavior/x86_64/math.zig referencing this issue!

@jacobly0 jacobly0 added bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. miscompilation The compiler reports success but produces semantically incorrect code. labels Feb 16, 2025
@jacobly0 jacobly0 added this to the 0.15.0 milestone Feb 16, 2025
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. miscompilation The compiler reports success but produces semantically incorrect code.
Projects
None yet
Development

No branches or pull requests

1 participant