diff options
| author | Michael Dusan <michael.dusan@gmail.com> | 2019-06-24 15:30:28 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-06-24 16:25:18 -0400 |
| commit | de2b0cd722ca8fe98d16c86825db4cb2a70931c6 (patch) | |
| tree | 04124d8ac7ac014635c3fa97bee3e765bc81cfe0 | |
| parent | 24400d5882aa2b83a4aed3e4c1503d0393e1c541 (diff) | |
| download | zig-de2b0cd722ca8fe98d16c86825db4cb2a70931c6.tar.gz zig-de2b0cd722ca8fe98d16c86825db4cb2a70931c6.zip | |
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;
| -rw-r--r-- | src/ir.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 5a4a53b804..0c79316652 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -23280,10 +23280,16 @@ static void ir_eval_float_op(IrAnalyze *ira, IrInstructionFloatOp *source_instr, BuiltinFnId fop = source_instr->op; unsigned bits; - if (float_type->id == ZigTypeIdComptimeFloat) { + switch (float_type->id) { + case ZigTypeIdComptimeFloat: bits = 128; - } else if (float_type->id == ZigTypeIdFloat) + break; + case ZigTypeIdFloat: bits = float_type->data.floating.bit_count; + break; + default: + zig_unreachable(); + } switch (bits) { case 16: { |
