Skip to content

Segmentation fault in compiler when address of comptime var passed to inline asm #22887

@joedavis

Description

@joedavis

Zig Version

0.14.0-dev.3219+bffbc918e

Steps to Reproduce and Observed Behavior

comptime.zig:

pub fn main() void {
    comptime var foo: i64 = 0;
    asm volatile (""
        :
        : [foo] "m" (&foo),
    );
}

Output when compiling:

$  zig build-exe comptime.zig
Segmentation fault (core dumped)

Expected Behavior

A diagnostic similar to that given when attempting to use @intFromPtr at compile time:

comptime.zig:3:25: error: runtime value contains reference to comptime var
    var x = @intFromPtr(&foo);

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