<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - Void functions marked pure attribute are not called"
href="http://llvm.org/bugs/show_bug.cgi?id=22802">22802</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Void functions marked pure attribute are not called
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.5
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>fuscated@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>I'm testing if the pure attribute is useful and stumbled upon this problem
case:
--- test_pure.cpp
#include <stdio.h>
void myPure(void *ptr) __attribute__ ((pure));
void myPure(void *ptr) {
float *p=reinterpret_cast<float*>(ptr);
p[0]=1.0f;
p[1]=2.0f;
p[2]=3.0f;
}
int main() {
float f[3]={};
myPure(f);
printf("f %.3f, %.3f, %.3f\n", f[0], f[1], f[2]);
return 0;
}
$ clang++-3.5 -Weverything test_pure.cpp
$ ./a.out
f 0.000, 0.000, 0.000
The result is that the function is not called, because it is void function.
Ideally I would be happy if the compiler can detect that ptr is an output
parameter and thus treat the function as having void* output.
I'm not sure if this is possible to implement, but if not I'd be happy if the
compiler emits a warning or an error when it detects this case.</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>