[llvm-bugs] [Bug 28304] New: Private template method address for default argument compiles fine with GCC but not with Clang
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Jun 25 10:55:12 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=28304
Bug ID: 28304
Summary: Private template method address for default argument
compiles fine with GCC but not with Clang
Product: clang
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: johnmph at gmail.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
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;
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160625/62febd1b/attachment.html>
More information about the llvm-bugs
mailing list