<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 - [N2439] Clang does NOT issue a diagnostic on ill-formed overloaded member functions"
href="https://bugs.llvm.org/show_bug.cgi?id=41995">41995</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[N2439] Clang does NOT issue a diagnostic on ill-formed overloaded member functions
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>8.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>pclove1@gmail.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># Overview:
According to
[N2439](<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm</a>),
<span class="quote">> Member function declarations with the same name and the same parameter-type-list, as well as member function template declarations with the same name, the same parameter-type-list, and the same template parameter lists, cannot be overloaded if any of them, but not all, have a ref-qualifier (8.3.5).</span >
# Steps to Reproduce:
```
class Base {
public:
void f() const {}
};
class Derived : public Base {
public:
using Base::f;
void f() & {}
void f() && {}
};
int main() {
const Derived cd;
cd.f();
return 0;
}
```
# Actual Results:
Clang compiles the above example without a diagnostic.
# Expected Results:
Clang issues a diagnostic.
# Build Date & Hardware:
clang version 8.0.0 (tags/RELEASE_800/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
# Additional Information:
- godbolt link to explore the example online.
- <a href="https://godbolt.org/z/vEYRIU">https://godbolt.org/z/vEYRIU</a>
- x86-64 gcc 9.1 issues a diagnostic on the above example.
```
<source>: In function 'int square(int)':
<source>:15:10: error: passing 'const Derived' as 'this' argument discards
qualifiers [-fpermissive]
15 | cd.f();
| ^
<source>:9:7: note: in call to 'int Derived::f() &'
9 | int f() & { return 2; }
| ^
Compiler returned: 1
```</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>