diff --git a/src/ir.cpp b/src/ir.cpp index 3c16c8251a..84daf645b9 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -23254,9 +23254,7 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ return result; } - IrInstruction *result = ir_build_bit_cast_gen(ira, source_instr, value, dest_type); - ir_assert(!(handle_is_ptr(dest_type) && !handle_is_ptr(src_type)), source_instr); - return result; + return ir_build_bit_cast_gen(ira, source_instr, value, dest_type); } static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, diff --git a/test/stage1/behavior/bitcast.zig b/test/stage1/behavior/bitcast.zig index 39f3d5d8d9..e86c50885e 100644 --- a/test/stage1/behavior/bitcast.zig +++ b/test/stage1/behavior/bitcast.zig @@ -95,20 +95,20 @@ test "@bitCast extern structs at runtime and comptime" { comptime S.doTheTest(); } -//test "bitcast packed struct to integer and back" { -// const LevelUpMove = packed struct { -// move_id: u9, -// level: u7, -// }; -// const S = struct { -// fn doTheTest() void { -// var move = LevelUpMove{ .move_id = 1, .level = 2 }; -// var v = @bitCast(u16, move); -// var back_to_a_move = @bitCast(LevelUpMove, v); -// expect(back_to_a_move.move_id == 1); -// expect(back_to_a_move.level == 2); -// } -// }; -// S.doTheTest(); -// comptime S.doTheTest(); -//} +test "bitcast packed struct to integer and back" { + const LevelUpMove = packed struct { + move_id: u9, + level: u7, + }; + const S = struct { + fn doTheTest() void { + var move = LevelUpMove{ .move_id = 1, .level = 2 }; + var v = @bitCast(u16, move); + var back_to_a_move = @bitCast(LevelUpMove, v); + expect(back_to_a_move.move_id == 1); + expect(back_to_a_move.level == 2); + } + }; + S.doTheTest(); + comptime S.doTheTest(); +}