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

Invalid code gen when passing none % 8 == 0 sized field to a function taking a &const to the fields type #966

Closed
Hejsil opened this Issue Apr 29, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@Hejsil
Member

Hejsil commented Apr 29, 2018

fn toInt(value: *const u7) u7 {
    return value.*;
}

pub const LevelUpMove = packed struct {
    move_id: u9,
    level: u7,
};

test "" {
    var lup: LevelUpMove = undefined;
    _ = toInt(lup.level);
}
Call parameter type does not match function signature!
  %2 = getelementptr inbounds %LevelUpMove, %LevelUpMove* %lup, i32 0, i32 0, !dbg !618
 i7*  %3 = call fastcc i7 @toInt(i16* %2), !dbg !620
LLVM ERROR: Broken module found, compilation aborted!

@andrewrk andrewrk added this to the 0.3.0 milestone Apr 29, 2018

@andrewrk andrewrk added the bug label Apr 29, 2018

@andrewrk

This comment has been minimized.

Member

andrewrk commented Sep 18, 2018

Ah, this is a missing compile error. Here's the error you get if you explicitly pass a pointer:

test.zig:12:19: error: expected type '*const u7', found '*align(:9:16) u7'
    _ = toInt(&lup.level);
                  ^

@andrewrk andrewrk closed this in 5fd3af9 Sep 18, 2018

@andrewrk

This comment has been minimized.

Member

andrewrk commented Sep 18, 2018

I was able to make it work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment