<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 - __constant__ variable in anonymous namespace is optimized as if it could not be modified"
href="https://bugs.llvm.org/show_bug.cgi?id=51320">51320</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>__constant__ variable in anonymous namespace is optimized as if it could not be modified
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>12.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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>CUDA
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>kiwixz@outlook.com
</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=25102" name="attach_25102" title="code sample showcasing the issue">attachment 25102</a> <a href="attachment.cgi?id=25102&action=edit" title="code sample showcasing the issue">[details]</a></span>
code sample showcasing the issue
The best way to understand it is by looking at the attached code sample.
I tested it with: clang++ -L/usr/local/cuda/lib64 -lcudart
--cuda-gpu-arch=sm_30 -O3 main.cu && ./a.out
It works without `-O3`.
Expected output:
good = 10
bad = 20
good = 110
bad = 120
Bad output:
good = 10
bad = 20
good = 110
bad = 20</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>