-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
arch-x86_6464-bit x8664-bit x86backend-self-hostedbugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior
Milestone
Description
Zig Version
0.14.0-dev.839+a931bfada
Steps to Reproduce and Observed Behavior
Cannot compile this program:
const std = @import("std");
pub fn main() !void {
const bug = Bug {
.x = 100,
.y = 200,
};
// does not work
std.log.info("value: {d}", .{ bug.bug() });
// calling a non-self fn works:
//std.log.info("value: {d}", .{ no_bug(bug.x, bug.y) });
}
const Bug = struct {
x: f32,
y: ?f32,
const Self = @This();
fn bug(self: *const Self) f32 {
return if (self.y) |y| self.x - y else 0.0;
}
};
fn no_bug(x: f32, y: ?f32) f32 {
return if (y) |y_| x - y_ else 0.0;
}
zig run -fno-llvm -fno-lld src/main.zig
zig run -fno-llvm -fno-lld src/main.zig
error(x86_64_encoder): no encoding found for: none vsubss xmm0 xmm0 r32 none
src/main.zig:21:5: error: CodeGen failed to find a viable instruction. This is a bug in the Zig compiler.
fn bug(self: *const Self) f32 {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expected Behavior
It should print -100 when calling bug.bug()
.
lin72h and ofrank123
Metadata
Metadata
Assignees
Labels
arch-x86_6464-bit x8664-bit x86backend-self-hostedbugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior