[llvm-bugs] [Bug 44317] New: -Wconversion warning not detecting potential overflow

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Dec 16 15:32:41 PST 2019


            Bug ID: 44317
           Summary: -Wconversion warning not detecting potential overflow
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: leonardchan at google.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Given the following code:

typedef short unsigned int uint16_t;

uint16_t func(uint16_t x, uint16_t mask) {
  x += ~mask;
  return x;

GCC is able to emit a warning with `-Wconversion` on the `x += ~mask` which can
cause an unexpected overflow. We do not get any similar warning with
`-Wconversion` on clang though, which would be nice to have.

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/20191216/f9c7e19d/attachment.html>

More information about the llvm-bugs mailing list