File tree 1 file changed +31
-0
lines changed 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,14 @@ test "@ptrCast preserves alignment of bigger source" {
167
167
expect (@typeOf (ptr ) == * align (16 ) u8 );
168
168
}
169
169
170
+ fn give () anyerror ! u128 {
171
+ return 3 ;
172
+ }
173
+
174
+ test "return error union with 128-bit integer" {
175
+ expect (3 == try give ());
176
+ }
177
+
170
178
test "runtime known array index has best alignment possible" {
171
179
// take full advantage of over-alignment
172
180
var array align (4 ) = [_ ]u8 { 1 , 2 , 3 , 4 };
@@ -251,6 +259,29 @@ test "size of extern struct with 128-bit field" {
251
259
}
252
260
}
253
261
262
+ const DefaultAligned = struct {
263
+ nevermind : u32 ,
264
+ badguy : i128 ,
265
+ };
266
+
267
+ test "read 128-bit field from default aligned struct in stack memory" {
268
+ var default_aligned = DefaultAligned {
269
+ .nevermind = 1 ,
270
+ .badguy = 12 ,
271
+ };
272
+ expect (12 == default_aligned .badguy );
273
+ }
274
+
275
+ var default_aligned_global = DefaultAligned {
276
+ .nevermind = 1 ,
277
+ .badguy = 12 ,
278
+ };
279
+
280
+ test "read 128-bit field from default aligned struct in global memory" {
281
+
282
+ expect (12 == default_aligned_global .badguy );
283
+ }
284
+
254
285
test "alignment of extern() void" {
255
286
var runtime_nothing = nothing ;
256
287
const casted1 = @ptrCast (* const u8 , runtime_nothing );
You can’t perform that action at this time.
0 commit comments