c - Comparison operation being completely ignored -
I am trying to write a test program to create a library. This test program is supposed to test every possible value that goes into some functions. Here's the code:
zero test_int8_smr () {for (int i = INT8_MIN; i & lt; = INT8_MAX; i ++) {int8_t testval = i; Int8_t Results = from_int8_smr (to_int8_smr (TESTAL)); If (testle! = Result) {if (testval == 0x80) // If this statement is ignored {continue}; } Printf ("test_int8_smr () failed: testwall = 0x% 02hhX, result = 0x% 02hhX \ n", test, result); Return; }} Printf ("test_int8_smr () succeeds for all possible values. \ N"); }
Here is the output:
test_int8_smr () failed: testval = 0x80, result = 0x00
If the statement appears to be ignored:
if (testval == 0x80) {continue; }
This is very confusing, why any thoughts are arising and how to fix it?
testals
type int8_t
hence its possible values The range is -0x80
to 0x7f
. It can never be equal to 0x80
and thus the relation of equality is always false and subject to continuous folding and dead code removal.
Comments
Post a Comment