-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
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
0.12.0-dev.2341+92211135f
Steps to Reproduce and Observed Behavior
Just run the exe built using zig build-exe from code bellow:
const std = @import("std");
const App = struct {
scroll_pos: [2]u32 = .{ 0, 0 },
dirty: bool = false,
fn scrollGood(self: *App, offset: [2]i32) void {
const x = self.scroll_pos[0];
const y = self.scroll_pos[1];
inline for (0..2) |i| {
if (offset[i] >= 0) {
self.scroll_pos[i] +|= @bitCast(offset[i]);
} else {
self.scroll_pos[i] -|= @bitCast(-offset[i]);
}
}
std.log.info("{any} -> {any}", .{ .{ x, y }, self.scroll_pos });
if (self.scroll_pos[0] != x or self.scroll_pos[1] != y) {
self.dirty = true;
}
}
fn scrollBad(self: *App, offset: [2]i32) void {
const o = self.scroll_pos;
inline for (0..2) |i| {
if (offset[i] >= 0) {
self.scroll_pos[i] +|= @bitCast(offset[i]);
} else {
self.scroll_pos[i] -|= @bitCast(-offset[i]);
}
}
std.log.info("{any} -> {any}", .{ o, self.scroll_pos });
if (self.scroll_pos[0] != o[0] or self.scroll_pos[1] != o[1]) {
self.dirty = true;
}
}
};
pub fn main() void {
{
var app = App{};
app.scrollGood(.{ 0, 1 });
std.log.info("{}", .{app.dirty});
}
{
var app = App{};
app.scrollBad(.{ 0, 1 });
std.log.info("{}", .{app.dirty});
}
}outputs:
info: { 0, 0 } -> { 0, 1 }
info: true
info: { 0, 0 } -> { 0, 1 }
info: false
Expected Behavior
the output of scrollGood and scrollBad should be identical
info: { 0, 0 } -> { 0, 1 }
info: true
info: { 0, 0 } -> { 0, 1 }
info: true
Reactions are currently unavailable
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