<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 - 'const' qualifier on referenced decltype(type) isn't allowed by clang++"
href="https://bugs.llvm.org/show_bug.cgi?id=47569">47569</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>'const' qualifier on referenced decltype(type) isn't allowed by clang++
</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>FreeBSD
</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++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>yuri@tsoft.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>Created <span class=""><a href="attachment.cgi?id=23980" name="attach_23980" title="testcase-c++-const-decltype.cpp">attachment 23980</a> <a href="attachment.cgi?id=23980&action=edit" title="testcase-c++-const-decltype.cpp">[details]</a></span>
testcase-c++-const-decltype.cpp
The attached testcase adds 'const' and the reference symbol & to
decltype(Cls::field) to construct the return type of a function.
Compilation fails:
<span class="quote">> testcase-c++-const-decltype.cpp:10:2: warning: 'const' qualifier on reference type 'decltype(X::u[0][0][0])' (aka 'unsigned int &') has no effect [-Wignored-qualifiers]
> const decltype(X::u[0][0][0])& getXu(unsigned i1, unsigned i2, unsigned i3) const {
> ^~~~~~
> testcase-c++-const-decltype.cpp:11:10: error: binding reference of type 'unsigned int' to value of type 'const unsigned int' drops 'const' qualifier
> return x.u[i1][i2][i3];
> ^~~~~~~~~~~~~~~</span >
Replacing decltype(X::u[0][0][0]) with "unsigned" helps, but
decltype(X::u[0][0][0]) resolves to the same "unsigned" which should make
"const decltype(X::u[0][0][0])&" equivalent to "const unsigned&".
The testcase fails with clang-10, clang-11, clang-11, clang-12.</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>