<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><span class="vcard"><a class="email" href="mailto:john.brawn@arm.com" title="John Brawn <john.brawn@arm.com>"> <span class="fn">John Brawn</span></a>
</span> changed
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - Inconsistent behavior in FP_TO_UINT compared to gcc-4.9"
href="https://bugs.llvm.org/show_bug.cgi?id=24805">bug 24805</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">Status</td>
<td>NEW
</td>
<td>RESOLVED
</td>
</tr>
<tr>
<td style="text-align:right;">Resolution</td>
<td>---
</td>
<td>INVALID
</td>
</tr>
<tr>
<td style="text-align:right;">CC</td>
<td>
</td>
<td>john.brawn@arm.com
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - Inconsistent behavior in FP_TO_UINT compared to gcc-4.9"
href="https://bugs.llvm.org/show_bug.cgi?id=24805#c1">Comment # 1</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - Inconsistent behavior in FP_TO_UINT compared to gcc-4.9"
href="https://bugs.llvm.org/show_bug.cgi?id=24805">bug 24805</a>
from <span class="vcard"><a class="email" href="mailto:john.brawn@arm.com" title="John Brawn <john.brawn@arm.com>"> <span class="fn">John Brawn</span></a>
</span></b>
<pre>Adjusting the test case slightly to expand things out:
int main() {
a = a * b;
printf("%d", a);
return 0;
}
In 'a * b' as one operand is double the other is converted to double so the
result is a double. That then needs to be converted to unsigned char for the
assignment, which means we actually have:
int main() {
a = (unsigned char)((double)a * b);
printf("%d", a);
return 0;
}
According to section 6.3.1.4 of C99: 'If the value of the integral part cannot
be represented by the integer type, the behavior is undefined.' so here we have
undefined behaviour as 255*18=4590 which cannot be represented in unsigned
char.</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>