[llvm-bugs] [Bug 39519] New: clang incorrectly implements inc/dec?

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 1 08:05:18 PDT 2018


            Bug ID: 39519
           Summary: clang incorrectly implements inc/dec?
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lebedev.ri at gmail.com
                CC: llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

The C99 standard ( appears to be very clear on this point: "The
expression ++E is equivalent to (E+=1)."

[17:52:50] <TNorthover> LebedevRI: John Regehr is right.
[17:53:32] <TNorthover> It also says "See the discussions of additive operators
for information on [...] conversions [...]".
[17:53:37] <LebedevRI> TNorthover: so clang is implementing inc/dec incorrectly
[17:54:25] <AaronBallman> LebedevRI: yeah, I agree with John on that

clang clearly does not do promotions in the c++; case.

The question at hand is:
* signed char c = 127; c++;
  Is this UB? UBSan does not catch it.
* unsigned char c = 255; c++;
  Is this (not ub!) unsigned integer overflow?
  Integer sanitizer does not catch it.

If these aren't ub/overflows, then the computation should be done in some
promoted type?
If the computation is not done in promoted type, then conversion sanitizer will
not catch it either.

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/20181101/8132ffaf/attachment.html>

More information about the llvm-bugs mailing list