Skip to content

Assertion failed when calling function returning struct with type member #586

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

Closed
scurest opened this issue Nov 5, 2017 · 0 comments
Closed
Labels
bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@scurest
Copy link
Contributor

scurest commented Nov 5, 2017

const assert = @import("std").debug.assert;

const Wrapper = struct { T: type };

fn wrap(comptime T: type) -> Wrapper {
    Wrapper { .T = T }
}

pub fn main() -> %void {
    const ty = wrap(i32).T;
    assert(ty == i32);
    
    // this works:
    // vvvvvvvvvvv
    //const ty = (Wrapper { .T = i32 }).T;
    //assert(ty == i32);
}

fails during compilation with

zig:
    /home/scurest/zig/src/codegen.cpp:4178:
    LLVMOpaqueValue* build_alloca(CodeGen*, TypeTableEntry*, const char*, uint32_t):
    Assertion `alignment > 0' failed.
Aborted (core dumped)
@andrewrk andrewrk added the bug Observed behavior contradicts documented or intended behavior label Nov 5, 2017
@andrewrk andrewrk added this to the 0.2.0 milestone Nov 5, 2017
@andrewrk andrewrk modified the milestones: 0.2.0, 0.3.0 Mar 14, 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

2 participants