forked from OSchip/llvm-project
[lldb] Reland "Fix UB in half2float" to fix the ubsan bot.
This relands part of the UB fix in4b074b49be
. The original commit also added some additional tests that uncovered some other issues (see D102845). I landed all the passing tests in48780527dd
and this patch is now just fixing the UB in half2float. See D102846 for a proposed rewrite of the function. Original commit message: The added DumpDataExtractorTest uncovered that this is lshifting a negative integer which upsets ubsan and breaks the sanitizer bot. This patch just changes the variable we shift to be unsigned.
This commit is contained in:
parent
5ccc79dc38
commit
42a9c0c80c
|
@ -52,7 +52,9 @@ static float half2float(uint16_t half) {
|
|||
float f;
|
||||
uint32_t u;
|
||||
} u;
|
||||
int32_t v = (int16_t)half;
|
||||
// Sign extend to 4 byte.
|
||||
int32_t sign_extended = static_cast<int16_t>(half);
|
||||
uint32_t v = static_cast<uint32_t>(sign_extended);
|
||||
|
||||
if (0 == (v & 0x7c00)) {
|
||||
u.u = v & 0x80007FFFU;
|
||||
|
|
Loading…
Reference in New Issue