<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 --- - Clang accepts invalid code that mutates a const parameter when it is defined with a 'const' qualifier but declared without the 'const' in a class template"
href="https://llvm.org/bugs/show_bug.cgi?id=31607">31607</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang accepts invalid code that mutates a const parameter when it is defined with a 'const' qualifier but declared without the 'const' in a class template
</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>All
</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++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>arphaman@gmail.com
</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>Clang fails to report an error that it "cannot assign to variable 'b' with
const-qualified type" given the following piece of code:
template<class T = int>
struct A
{
struct B {};
const B* test (const B* b) const;
};
template<class T>
inline auto A< T >::test (const B* const b) const -> const B*
{
return ++b; // expected an error here
}
int main()
{
A<> m;
const A<>::B* b = 0;
b = m.test (b);
}
The AST dumps show that the specialisation of method test from class A has the
following parameter declaration:
ParmVarDecl 0x7fba11802228 <col:17, col:26> col:26 used b 'const struct
A<int>::B *'
but the non-specialised definition of the method test has the following
parameter declaration:
ParmVarDecl 0x7fba11800e90 <col:27, col:42> col:42 referenced b 'const struct
A::B *const'
This makes me think that the error isn't reported because the 'const' qualifier
isn't given to the parameter in the specialised method definition.</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>