<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 --- - Private template method address for default argument compiles fine with GCC but not with Clang"
href="https://llvm.org/bugs/show_bug.cgi?id=28304">28304</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Private template method address for default argument compiles fine with GCC but not with Clang
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>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>johnmph@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>This code compiles with GCC but not with Clang ("'func' is a private member of
'Test'" error) :
#include <iostream>
#include <functional>
int func3() { return 3; }
struct Test {
template <typename F = std::function<int (void)>> Test(F &&f = func<int>) :
_f(std::forward<F>(f)) {} // Compile only with GCC
//template <typename F = std::function<int (void)>> Test(F &&f = func2) :
_f(std::forward<F>(f)) {} // Compile with GCC and Clang
//Test (std::function<int (void)> f = func<int>) : _f(f) {} // Compile with
GCC and Clang
int get() const { return _f(); }
private:
template <typename T> static T func() { return 1; }
static int func2() { return 2; }
std::function<int (void)> _f;
};
int main() {
Test t1, t2(func3);
std::cout << t1.get() << ", " << t2.get() << std::endl;
}</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>