Skip to content

Sema: incorrectly multiplies float vectors containing zeros at comptime #22743

@jacobly0

Description

@jacobly0
const nan = @import("std").math.nan;
comptime {
    @compileLog(nan(f32) * @as(f32, 0));
    @compileLog(@Vector(1, f32){nan(f32)} * @Vector(1, f32){0});
}
$ zig build-obj repro.zig
repro.zig:3:5: error: found compile log statement
    @compileLog(nan(f32) * @as(f32, 0));
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Compile Log Output:
@as(f32, nan)
@as(@Vector(1, f32), .{ 0 })

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions