File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -10133,7 +10133,7 @@ fn llvmFieldIndex(
10133
10133
llvm_field_index += 1 ;
10134
10134
}
10135
10135
10136
- if (field_index = = i ) {
10136
+ if (field_index < = i ) {
10137
10137
ptr_pl_buf .* = .{
10138
10138
.data = .{
10139
10139
.pointee_type = field_ty ,
@@ -10166,7 +10166,7 @@ fn llvmFieldIndex(
10166
10166
llvm_field_index += 1 ;
10167
10167
}
10168
10168
10169
- if (field_index = = i ) {
10169
+ if (field_index < = i ) {
10170
10170
ptr_pl_buf .* = .{
10171
10171
.data = .{
10172
10172
.pointee_type = field .ty ,
Original file line number Diff line number Diff line change @@ -1398,3 +1398,23 @@ test "under-aligned struct field" {
1398
1398
const result = std .mem .readIntNative (u64 , array [4.. 12]);
1399
1399
try expect (result == 1234 );
1400
1400
}
1401
+
1402
+ test "address of zero-bit field is equal to address of only field" {
1403
+ if (builtin .zig_backend == .stage2_x86_64 ) return error .SkipZigTest ; // TODO
1404
+ if (builtin .zig_backend == .stage2_aarch64 ) return error .SkipZigTest ; // TODO
1405
+ if (builtin .zig_backend == .stage2_arm ) return error .SkipZigTest ; // TODO
1406
+ if (builtin .zig_backend == .stage2_c ) return error .SkipZigTest ; // TODO
1407
+
1408
+ {
1409
+ const A = struct { b : void = {}, u : u8 };
1410
+ var a = A { .u = 0 };
1411
+ const a_ptr = @fieldParentPtr (A , "b" , & a .b );
1412
+ try std .testing .expectEqual (& a , a_ptr );
1413
+ }
1414
+ {
1415
+ const A = struct { u : u8 , b : void = {} };
1416
+ var a = A { .u = 0 };
1417
+ const a_ptr = @fieldParentPtr (A , "b" , & a .b );
1418
+ try std .testing .expectEqual (& a , a_ptr );
1419
+ }
1420
+ }
You can’t perform that action at this time.
0 commit comments