diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2023-09-21 02:00:52 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-09-21 14:48:41 -0700 |
| commit | 1b672e41c528b0aa225cbe07c61203d04b2d9034 (patch) | |
| tree | 080cac4fbde495c9b216fac1cd67e84799740059 /src/value.zig | |
| parent | cd242b7440e11d9997c33296b3974dfb1fbd5d95 (diff) | |
| download | zig-1b672e41c528b0aa225cbe07c61203d04b2d9034.tar.gz zig-1b672e41c528b0aa225cbe07c61203d04b2d9034.zip | |
InternPool,Sema,type,llvm: alignment fixes
This changeset fixes the handling of alignment in several places. The
new rules are:
* `@alignOf(T)` where `T` is a runtime zero-bit type is at least 1,
maybe greater.
* Zero-bit fields in `extern` structs *do* force alignment, potentially
offsetting following fields.
* Zero-bit fields *do* have addresses within structs which can be
observed and are consistent with `@offsetOf`.
These are not necessarily all implemented correctly yet (see disabled
test), but this commit fixes all regressions compared to master, and
makes one new test pass.
Diffstat (limited to 'src/value.zig')
| -rw-r--r-- | src/value.zig | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/value.zig b/src/value.zig index 9edd1059db..2d0523f986 100644 --- a/src/value.zig +++ b/src/value.zig @@ -1265,7 +1265,8 @@ pub const Value = struct { .int => |int| switch (int.storage) { .big_int => |big_int| big_int.orderAgainstScalar(0), inline .u64, .i64 => |x| std.math.order(x, 0), - .lazy_align, .lazy_size => |ty| return if (ty.toType().hasRuntimeBitsAdvanced( + .lazy_align => .gt, // alignment is never 0 + .lazy_size => |ty| return if (ty.toType().hasRuntimeBitsAdvanced( mod, false, if (opt_sema) |sema| .{ .sema = sema } else .eager, |
