authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2019-06-24 15:30:28-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-24 16:25:18-04:00
logde2b0cd722ca8fe98d16c86825db4cb2a70931c6
tree04124d8ac7ac014635c3fa97bee3e765bc81cfe0
parent24400d5882aa2b83a4aed3e4c1503d0393e1c541

fix compile error when building zig w/ clang

errors as reported on macOS w/ Xcode 10.1, 10.2 and 11.0: src/ir.cpp:23285:16: error: variable 'bits' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] } else if (float_type->id == ZigTypeIdFloat) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/ir.cpp:23288:13: note: uninitialized use occurs here switch (bits) { ^~~~ src/ir.cpp:23285:12: note: remove the 'if' if its condition is always true } else if (float_type->id == ZigTypeIdFloat) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/ir.cpp:23281:18: note: initialize the variable 'bits' to silence this warning unsigned bits;

1 files changed, 8 insertions(+), 2 deletions(-)

src/ir.cpp+8-2
...@@ -23280,10 +23280,16 @@ static void ir_eval_float_op(IrAnalyze *ira, IrInstructionFloatOp *source_instr,...@@ -23280,10 +23280,16 @@ static void ir_eval_float_op(IrAnalyze *ira, IrInstructionFloatOp *source_instr,
23280 BuiltinFnId fop = source_instr->op;23280 BuiltinFnId fop = source_instr->op;
23281 unsigned bits;23281 unsigned bits;
2328223282
23283 if (float_type->id == ZigTypeIdComptimeFloat) {23283 switch (float_type->id) {
23284 case ZigTypeIdComptimeFloat:
23284 bits = 128;23285 bits = 128;
23285 } else if (float_type->id == ZigTypeIdFloat)23286 break;
23287 case ZigTypeIdFloat:
23286 bits = float_type->data.floating.bit_count;23288 bits = float_type->data.floating.bit_count;
23289 break;
23290 default:
23291 zig_unreachable();
23292 }
2328723293
23288 switch (bits) {23294 switch (bits) {
23289 case 16: {23295 case 16: {