<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 - Incorrect optimization results cause branch redirection errors."
href="https://bugs.llvm.org/show_bug.cgi?id=51410">51410</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Incorrect optimization results cause branch redirection errors.
</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>Windows NT
</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>C
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>2077213809@qq.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>I have the following test case. The problem occurs on the ARM platform. It
seems that the problem is caused by Clang optimization. I expected to enter the
return 1 branch of the foo function, but actually enter return 0, which is
normal only when O2 optimization occurs.
clang --target=arm-none-eabi -O2 test.c
#include <stdio.h>
typedef struct {
void *pPtAddr;
unsigned int uwPtSize;
} Node;
unsigned int foo(unsigned int ucPtNo, Node *para) {
char *pcPtEnd;
pcPtEnd = (char *)para->pPtAddr + para->uwPtSize;
if ((unsigned int)para->pPtAddr >= (unsigned int)pcPtEnd) {
return 1;
}
printf("unexcetion print %p %p\n", para->pPtAddr, pcPtEnd);
return 0;
}
int main() {
Node para;
para.pPtAddr = (void *)0xffffffff;
para.uwPtSize = 0xfff;
int res = foo(32, ¶);
printf("%d\n", res);
return 0;
}</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>