-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
backend-llvmThe LLVM backend outputs an LLVM IR Module.The LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior
Milestone
Description
Zig Version
zig-0.12.0-dev.3489+c808e546a
Steps to Reproduce and Observed Behavior
Compile and run the following code
const std = @import("std");
const A = struct{
fn u(self: *@This()) *U {
return @fieldParentPtr(U,"a",self);
}
};
const B = struct{
fn u(self: *@This()) *U {
return @fieldParentPtr(U,"b",self);
}
};
const U = union(enum) { a: A, b: B };
pub fn main() !void {
var u: U = .{ .a = .{} };
const pa = &u.a;
const pu = 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.
3B477FFB76 3B477FFB77
Tested on x86_64 and Aarch64.
Expected Behavior
Expected both values to be equal.
RossComputerGuy
Metadata
Metadata
Assignees
Labels
backend-llvmThe LLVM backend outputs an LLVM IR Module.The LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior