<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - clang incorrectly implements inc/dec?"
href="https://bugs.llvm.org/show_bug.cgi?id=39519">39519</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang incorrectly implements inc/dec?
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>lebedev.ri@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre><a href="https://reviews.llvm.org/D53949#1282884">https://reviews.llvm.org/D53949#1282884</a>
@regehr
The C99 standard (6.5.3.1.2) 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
<a href="https://godbolt.org/z/qd-QV4">https://godbolt.org/z/qd-QV4</a>
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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>