Skip to content

Commit

Permalink
Fix build warning/error about converting a constant to a boolean (dot…
Browse files Browse the repository at this point in the history
…net#42389)

On Fedora 32 with Clang 10, I get this warning/error when building
coreclr:

    /home/omajid/devel/dotnet/runtime/src/coreclr/src/jit/emitarm.cpp:5553:31: error: converting the enum constant to a boolean [-Werror,-Wint-in-bool-context]
            assert(ins == INS_cbz || INS_cbnz);
                                  ^

This looks like a bug that should be fixed: ins should be compared with
the constant on both sides of the boolean operator. Otherwise the
conditional can always evaluate to true.
  • Loading branch information
omajid authored Sep 18, 2020
1 parent 527f9ae commit bbacfec
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/emitarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5550,7 +5550,7 @@ BYTE* emitter::emitOutputShortBranch(BYTE* dst, instruction ins, insFormat fmt,
else if (fmt == IF_T1_I)
{
assert(id != NULL);
assert(ins == INS_cbz || INS_cbnz);
assert(ins == INS_cbz || ins == INS_cbnz);
assert((distVal & 1) == 0);
assert(distVal >= 0);
assert(distVal <= 126);
Expand Down

0 comments on commit bbacfec

Please sign in to comment.