authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-12-15 19:25:41+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-15 16:23:42-05:00
log59de23dfa010c5556f79fbb8b4c637c8d150fd88
tree0b54e104539ef236d979d26bae14283f49ef44ea
parentb169f7b0d51fa9e7cf570479079369b9736093ff

Don't assume TLS storage has a fixed address

Fixes #3433

2 files changed, 9 insertions(+), 1 deletions(-)

src/ir.cpp+1-1
......@@ -17395,7 +17395,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction,
1739517395 result->value->type = get_pointer_to_type_extra(ira->codegen, var->var_type,
1739617396 var->src_is_const, is_volatile, PtrLenSingle, var->align_bytes, 0, 0, false);
1739717397
17398 if (linkage_makes_it_runtime)
17398 if (linkage_makes_it_runtime || var->is_thread_local)
1739917399 goto no_mem_slot;
1740017400
1740117401 if (value_is_comptime(var->const_value)) {
test/stage1/behavior/misc.zig+8
......@@ -773,3 +773,11 @@ test "result location is optional inside error union" {
773773 const x = maybe(true) catch unreachable;
774774 expect(x.? == 42);
775775}
776
777threadlocal var buffer: [11]u8 = undefined;
778
779test "pointer to thread local array" {
780 const s = "Hello world";
781 std.mem.copy(u8, buffer[0..], s);
782 std.testing.expectEqualSlices(u8, buffer[0..], s);
783}