Skip to content

stage2 miscompilation involving vectors #12026

@xxxbxxx

Description

@xxxbxxx

Zig Version

0.10.0-dev.2895+3486d8dd2

Steps to Reproduce

const std = @import("std");

const Vec3 = @Vector(3, i32);

test {
    var arena_alloc = std.heap.ArenaAllocator.init(std.testing.allocator);
    defer arena_alloc.deinit();
    const arena = arena_alloc.allocator();

    var points = std.ArrayList(Vec3).init(arena);

    try points.append(Vec3{ 404, -588, -901 });
    try points.append(Vec3{ 528, -643, 409 });
    try points.append(Vec3{ -838, 591, 734 });
    try points.append(Vec3{ 390, -675, -793 });
    try points.append(Vec3{ -537, -823, -458 });
    try points.append(Vec3{ -485, -357, 347 });
    try points.append(Vec3{ -345, -311, 381 });
    try points.append(Vec3{ -661, -816, -575 });

    try std.testing.expectEqual(points.items[6], Vec3{ -345, -311, 381 });      // ok 

    // adding one more fails. (arraylist reallocs..)
    try points.append(Vec3{ -876, 649, 763 });
    try std.testing.expectEqual(points.items[6], Vec3{ -345, -311, 381 });      // fails
}

Expected Behavior

success

(and does with stage1)

Actual Behavior

Test [1/1] test_0... index 0 incorrect. expected -345, found -1431655766
Test [1/1] test_0... FAIL (TestExpectedEqual)

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend-llvmThe LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.miscompilationThe compiler reports success but produces semantically incorrect code.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions