Skip to content

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

Closed

Description

@scurest
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)

Activity

  1. added
    bugObserved behavior contradicts documented or intended behavior
    on Nov 5, 2017
  2. added this to the 0.2.0 milestone on Nov 5, 2017
  3. modified the milestones: 0.2.0, 0.3.0 on Mar 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions