File tree 1 file changed +6
-0
lines changed 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -462,6 +462,8 @@ pub const ET = enum(u16) {
462
462
/// Core file
463
463
CORE = 4 ,
464
464
465
+ _ ,
466
+
465
467
/// Beginning of OS-specific codes
466
468
pub const LOOS = 0xfe00 ;
467
469
@@ -532,17 +534,21 @@ pub const Header = struct {
532
534
};
533
535
const need_bswap = endian != native_endian ;
534
536
537
+ // Converting integers to exhaustive enums using `@enumFromInt` could cause a panic.
538
+ comptime assert (! @typeInfo (OSABI ).@"enum" .is_exhaustive );
535
539
const os_abi : OSABI = @enumFromInt (hdr32 .e_ident [EI_OSABI ]);
536
540
537
541
// The meaning of this value depends on `os_abi` so just make it available as `u8`.
538
542
const abi_version = hdr32 .e_ident [EI_ABIVERSION ];
539
543
540
544
const @"type" = if (need_bswap ) blk : {
545
+ comptime assert (! @typeInfo (ET ).@"enum" .is_exhaustive );
541
546
const value = @intFromEnum (hdr32 .e_type );
542
547
break :blk @as (ET , @enumFromInt (@byteSwap (value )));
543
548
} else hdr32 .e_type ;
544
549
545
550
const machine = if (need_bswap ) blk : {
551
+ comptime assert (! @typeInfo (EM ).@"enum" .is_exhaustive );
546
552
const value = @intFromEnum (hdr32 .e_machine );
547
553
break :blk @as (EM , @enumFromInt (@byteSwap (value )));
548
554
} else hdr32 .e_machine ;
You can’t perform that action at this time.
0 commit comments