[llvm-bugs] [Bug 44054] New: Missing overflow check for ++x compared to x += 1

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 19 02:05:25 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=44054

            Bug ID: 44054
           Summary: Missing overflow check for ++x compared to x += 1
           Product: compiler-rt
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ubsan
          Assignee: unassignedbugs at nondot.org
          Reporter: cullmann at absint.de
                CC: llvm-bugs at lists.llvm.org

If you use this example:

int main()
{
    signed char x = 127;
    x += 1;
    return 0;
}

with -fsanitize=integer you get a proper:

main.cpp:4:7: runtime error: implicit conversion from type 'int' of value 128
(32-bit, signed) to type 'signed char' changed the value to -128 (8-bit,
signed)

If you alter this to

int main()
{
    signed char x = 127;
    ++x;
    return 0;
}

no longer any check is done. In the IR already the call to the overflow stuff
is missing.

I am not sure if this is the right component to report, thought.
(Or if I miss some option to get this kind of overflow alarm)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191119/d715c5a5/attachment.html>


More information about the llvm-bugs mailing list