<html>
<head>
<base href="https://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 --- - partial template specialisation of constness of the decltype of a static const member via operator. yields nonconst"
href="https://llvm.org/bugs/show_bug.cgi?id=30700">30700</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>partial template specialisation of constness of the decltype of a static const member via operator. yields nonconst
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.8
</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>C++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>peter.maucher@arcor.de
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=17443" name="attach_17443" title="test case in readable">attachment 17443</a> <a href="attachment.cgi?id=17443&action=edit" title="test case in readable">[details]</a></span>
test case in readable
Hi everyone
at the following example the compiler uses the wrong template specialisation,
as marked by the comments.
/** begin test */
template<typename Test>
struct is_const { const static bool is_constant = false; };
template<typename Test>
struct is_const<const Test> { const static bool is_constant = true; };
class to_test { public: const static unsigned member = 5; };
int main() {
to_test tester;
std::cout << is_const<decltype(tester.member)>::is_constant << " " <<
// =0, should be 1
is_const<decltype(to_test::member)>::is_constant << " " << // =1
std::endl;
//decltype(tester.member) x1 (5);
//decltype(to_test::member) x2(5);
//std::cout << ++x1 << " " << ++x2 << std::endl; // ++x1 fails because
const
}
/** end test */
according to the output of cout, the template resolution fails if I use the
operator. and decltype to get the type, but clang successfully forbids to alter
variables of decltype(tester.member) because it is const-qualified.
I've appended the file in a little more readable and some more tests of
combinations of const and static.</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>