Segfault using anonymous tuple struct
Zig Version
0.14.0-dev.367+a57479afc
Steps to Reproduce and Observed Behavior
In the following code, replacing any usage of IntRange with struct { i32, i32 } will result in a segmentation fault:
const std = @import("std");
const debug = std.debug;
const math = std.math;
const sort = std.sort;
const IntRange = struct { i32, i32 };
pub fn main() void {
const items = [_]IntRange{ // segfaults with struct { i32, i32 }
.{ 1, 25 },
.{ 26, 50 },
.{ 51, 75 },
.{ 76, 100 },
};
const key: i32 = 42;
const index = sort.binarySearch(IntRange, key, &items, {}, compareFn); // segfaults with struct { i32, i32 }
debug.print("{?}\n", .{index});
}
fn compareFn(_: void, key: i32, mid_item: struct { i32, i32 }) math.Order {
const lo, const hi = mid_item;
return if (key < lo) .lt else if (key > hi) .gt else .eq;
}
Expected Behavior
No segfault
looks like a duplicate of https://github.com/ziglang/zig/issues/19497
None of the examples in that issue are giving me a segfault 🤔
#20415 and #20746 look similar to my issue, though
interesting, testing myself and yeah youre right. seems @Vexu mightve been wrong about the others being duplicates?
Only the third example in #19497 crashes now but it is different from this. The other two are the same as this one.