Skip to content

no align available for type '.cimport:1:15.struct_google_protobuf_Timestamp' #12122

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
calvin2021y opened this issue Jul 14, 2022 · 3 comments
Closed
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@calvin2021y
Copy link

Zig Version

0.10.0-dev.2880+6f0807f50

Steps to Reproduce

when import this header

#define UPB_PTR_AT(msg, ofs, type) ((type*)((char*)(msg) + (ofs)))

typedef struct google_protobuf_Timestamp google_protobuf_Timestamp;

UPB_INLINE void ptest_Message_NestedMessage_set_v(test_Message *msg, struct google_protobuf_Timestamp* value) {
  _upb_sethas(msg, 1);
  *UPB_PTR_AT(msg, UPB_SIZE(4, 8), struct google_protobuf_Timestamp*) = value;
}

Expected Behavior

the struct google_protobuf_Timestamp only used as pointer from c header file, no align is inused here.

Actual Behavior

zig/lib/zig/std/meta.zig:127:37: error: no align available for type '.cimport:1:15.struct_google_protobuf_Timestamp'
        .Optional => |info| switch (@typeInfo(info.child)) {
                                    ^
./zig-cache/o/250f5ec71ae498243a4415486ebd8496/cimport.zig:7378:94: note: called from here
    @ptrCast([*c]?*struct_google_protobuf_Timestamp, @alignCast(@import("std").meta.alignment(?*struct_google_protobuf_Timestamp), @ptrCast([*c]u8, @alignCast(@import("std").meta.alignment(u8), msg)) + @bitCast(usize, @intCast(isize, @as(c_int, 8))))).* = value;
                                                                                             ^
./zig-cache/o/250f5ec71ae498243a4415486ebd8496/cimport.zig:7374:147: note: called from here
pub fn ptest_Message_set_v(arg_msg: ?*ptest_Message, arg_value: ?*struct_google_protobuf_Timestamp) callconv(.C) void {
                                                                                                                                                  ^
pub fn ptest_Message_set_v(arg_msg: ?*ptest_Message arg_value: ?*struct_google_protobuf_Timestamp) callconv(.C) void {
    var msg = arg_msg;
    var value = arg_value;
    _upb_sethas(@ptrCast(?*const upb_Message, msg), @bitCast(usize, @as(c_long, @as(c_int, 1))));
    @ptrCast([*c]?*struct_google_protobuf_Timestamp, @alignCast(@import("std").meta.alignment(?*struct_google_protobuf_Timestamp), @ptrCast([*c]u8, @alignCast(@import("std").meta.alignment(u8), msg)) + @bitCast(usize, @intCast(isize, @as(c_int, 8))))).* = value;
}
@calvin2021y calvin2021y added the bug Observed behavior contradicts documented or intended behavior label Jul 14, 2022
@Vexu
Copy link
Member

Vexu commented Jul 14, 2022

Duplicate of #10222, shouldn't be too difficult to fix if you're interested.

@Vexu Vexu closed this as not planned Won't fix, can't repro, duplicate, stale Jul 14, 2022
@calvin2021y
Copy link
Author

calvin2021y commented Jul 15, 2022

You mean fixed from C source code or zig ? I am not sure where to started. (just start learn zig yesterday, try zig cc fist to see if I can use my project with zig)

@Vexu
Copy link
Member

Vexu commented Jul 15, 2022

The bug is in Zig but after looking closer this is yet another case of #6706 so your best bet is to try to avoid this bug and wait for Zig 0.10.0 to be released.

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