You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The example below generates two functions. The Box<u32> in make_option's return type is correctly lowered to uint32_t * but for the EntryResult in make_result the codegen generates an opaque type that it uses incorrectly:
#include<stdarg.h>#include<stdbool.h>#include<stdint.h>#include<stdlib.h>typedefstructBox_u32Box_u32; // uh-ohtypedefenumEntryResult_Tag {
Ok,
Err,
} EntryResult_Tag;
typedefstructEntryResult {
EntryResult_Tagtag;
union {
struct {
// this is an incomplete type; it cannot be used here. Expected uint32 *.structBox_u32ok;
};
struct {
uint32_terr;
};
};
} EntryResult;
uint32_t*make_option(void);
structEntryResultmake_result(void);
My actual use case is pretty close to what's shown here: I want to return a Result type and since Result isn't repr(C) I roll my own. I've done this with other types that are repr(C) before, but this is the first time I've wanted to use a Box<T> and was surprised at the result (ha).
The text was updated successfully, but these errors were encountered:
The example below generates two functions. The
Box<u32>
inmake_option
's return type is correctly lowered touint32_t *
but for theEntryResult
inmake_result
the codegen generates an opaque type that it uses incorrectly:Generated C code (though I've added comments):
My actual use case is pretty close to what's shown here: I want to return a Result type and since Result isn't
repr(C)
I roll my own. I've done this with other types that are repr(C) before, but this is the first time I've wanted to use aBox<T>
and was surprised at the result (ha).The text was updated successfully, but these errors were encountered: