mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
25 lines
359 B
Zig
25 lines
359 B
Zig
const std = @import("std");
|
|
const expect = std.testing.expect;
|
|
|
|
const BitField = packed struct {
|
|
a: u3,
|
|
b: u3,
|
|
c: u2,
|
|
};
|
|
|
|
var bit_field = BitField{
|
|
.a = 1,
|
|
.b = 2,
|
|
.c = 3,
|
|
};
|
|
|
|
test "pointer to non-byte-aligned field" {
|
|
try expect(bar(&bit_field.b) == 2);
|
|
}
|
|
|
|
fn bar(x: *const u3) u3 {
|
|
return x.*;
|
|
}
|
|
|
|
// test_error=expected type
|