add regression tests for a bug fixed by an older commit

closes #1914
This commit is contained in:
Andrew Kelley 2019-03-23 19:01:33 -04:00
parent 4d50bc3f8d
commit 6a9c32f759
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
2 changed files with 32 additions and 0 deletions

View File

@ -20,6 +20,7 @@ comptime {
_ = @import("behavior/bugs/1486.zig");
_ = @import("behavior/bugs/1500.zig");
_ = @import("behavior/bugs/1851.zig");
_ = @import("behavior/bugs/1914.zig");
_ = @import("behavior/bugs/2006.zig");
_ = @import("behavior/bugs/394.zig");
_ = @import("behavior/bugs/421.zig");

View File

@ -0,0 +1,31 @@
const std = @import("std");
const A = struct {
b_list_pointer: *const []B,
};
const B = struct {
a_pointer: *const A,
};
const b_list: []B = []B{};
const a = A{ .b_list_pointer = &b_list };
test "segfault bug" {
const assert = std.debug.assert;
const obj = B{ .a_pointer = &a };
assert(obj.a_pointer == &a); // this makes zig crash
}
const A2 = struct {
pointer: *B,
};
pub const B2 = struct {
pointer_array: []*A2,
};
var b_value = B2{ .pointer_array = []*A2{} };
test "basic stuff" {
std.debug.assert(&b_value == &b_value);
}