mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
This is all of the expected 0.14.0 progress on #21530, which can now be postponed once this commit is merged. This required rewriting the (un)wrap operations since the original implementations were extremely buggy. Also adds an easy way to retrigger Sema OPV bugs so that I don't have to keep updating #22419 all the time.
31 lines
577 B
Zig
31 lines
577 B
Zig
const S = struct {
|
|
b: u32,
|
|
c: i32,
|
|
a: struct {
|
|
pub fn str(_: @This(), extra: []u32) []i32 {
|
|
return @bitCast(extra);
|
|
}
|
|
},
|
|
};
|
|
|
|
pub export fn entry() void {
|
|
var s: S = undefined;
|
|
_ = s.a.str(undefined);
|
|
}
|
|
|
|
const S2 = struct {
|
|
a: [*c]anyopaque,
|
|
};
|
|
|
|
pub export fn entry2() void {
|
|
var s: S2 = undefined;
|
|
_ = &s;
|
|
}
|
|
|
|
// error
|
|
// backend=stage2,llvm
|
|
// target=native
|
|
//
|
|
// :6:20: error: cannot @bitCast to '[]i32'
|
|
// :6:20: note: use @ptrCast to cast from '[]u32'
|
|
// :17:12: error: C pointers cannot point to opaque types
|