<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 strict-aliasing optimizations vs unreachable code"
href="https://bugs.llvm.org/show_bug.cgi?id=41178">41178</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang strict-aliasing optimizations vs unreachable code
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>7.0
</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>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>paul_st@list.ru
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=21640" name="attach_21640" title="test with unreachable code">attachment 21640</a> <a href="attachment.cgi?id=21640&action=edit" title="test with unreachable code">[details]</a></span>
test with unreachable code
Lets consider example r.c from attachment
$ clang-7.0 -O0 r.c -o r0.out
$ clang-7.0 -O1 r.c -fno-strict-aliasing -o r1.nsa.out
$ clang-7.0 -O1 r.c -o r1.sa.out
$ ./r0.out
this should be zero: 0
$ ./r1.nsa.out
this should be zero: 0
$ ./r1.sa.out
this should be zero: -1
static inline void __attribute__((always_inline)) longLongAssign( int cond,
char *ptr)
{
if ( cond )
{
*((long long *)ptr) = 0;
}
}
I suppose test doesn't violate strict-aliasing rule, because
1) argument "ptr" has type "char *"
2) condition "cond" is always zero
Why I got different results?
P.S. I am new therefore apologize for my mistakes.</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>