Zig Version
zig-0.12.0-dev.3489+c808e546a
Steps to Reproduce and Observed Behavior
Compile and run the following code
conststd=@import("std");
constA=struct{
fnu(self: *@This()) *U {
return@fieldParentPtr(U,"a",self);
}
};
constB=struct{
fnu(self: *@This()) *U {
return@fieldParentPtr(U,"b",self);
}
};
constU=union(enum) { a: A, b: B };
pubfnmain() !void {
varu: U= .{ .a= .{} };
constpa=&u.a;
constpu=pa.u();
std.debug.print("{X} {X}\n",.{@intFromPtr(pu),@intFromPtr(&u)});
}The code prints two address values, the first being 1 smaller than the second one. E.g.
Tested on x86_64 and Aarch64.
Expected Behavior
Expected both values to be equal.
Zig Version
zig-0.12.0-dev.3489+c808e546a
Steps to Reproduce and Observed Behavior
Compile and run the following code
The code prints two address values, the first being 1 smaller than the second one. E.g.
Tested on x86_64 and Aarch64.
Expected Behavior
Expected both values to be equal.