Skip to content

Inconsistent behavior of comptime variable reference with -fstrip #25438

@iRohith

Description

@iRohith

Zig Version

0.15.1

Steps to Reproduce and Observed Behavior

const std = @import("std");

pub fn main() !void {
    var r: i32 = 1;
    comptime var c: i32 = 2;
    const tuple = .{ &r, &c };
    std.debug.print("{}, {}\n", .{ tuple[0].*, tuple[1].* }); // 1, 2

    tuple[1].* = 4;
    std.debug.print("{}, {}\n", .{ tuple[0].*, tuple[1].* }); // 1, 4
}

Compiles and runs fine with zig run main.zig -fstrip

Segfaults without -fstrip or without .strip = true in build.zig.

Possible related issues: #24477, #24592

Expected Behavior

The program should behave consistently with or without the -fstrip flag, preferably compiling and running successfully, or otherwise producing an explicit compile error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions