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

SIGSEGV on comptime_int used as inline assembly input operand #1206

Closed
tiehuis opened this issue Jul 7, 2018 · 1 comment
Closed

SIGSEGV on comptime_int used as inline assembly input operand #1206

tiehuis opened this issue Jul 7, 2018 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@tiehuis
Copy link
Member

tiehuis commented Jul 7, 2018

pub fn main() void {
    const in = 5;
    var out: u32 = 0;

    const r = asm ("movl %%eax, %%ebx"
        : [out] "={ebx}" (-> u32)
        : [eax] "{eax}" (in)
    );

    @import("std").debug.assert(r == in);
}

Crashes with:

fish: “zig build-exe t.zig” terminated by signal SIGSEGV (Address boundary error)

Explicitly specifying the input operand width fixes the issue:

const in: u32 = 5;

Should suffice to omit a compile error on comptime_int given as a parameter. I know there is a lot of changes and improvements to the inline assembly system wanted anyway, so this isn't too important and can be left until #215 is decided.

@tiehuis tiehuis added the bug Observed behavior contradicts documented or intended behavior label Jul 7, 2018
@tiehuis tiehuis changed the title SIGSEGV on inline assembly comptime_int with inline assembly input operand SIGSEGV on comptime_int used as inline assembly input operand Jul 7, 2018
@tiehuis
Copy link
Member Author

tiehuis commented Jul 7, 2018

Just saw that this is a duplicate of #728.

@tiehuis tiehuis closed this as completed Jul 7, 2018
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
Projects
None yet
Development

No branches or pull requests

1 participant