http://llvm.org/bugs/show_bug.cgi?id=17030
Bug ID: 17030
Summary: Clang in C++11 mode refuses to get address of
templated function as template parameter
Product: clang
Version: 3.1
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
Apple's Clang that ships with Xcode 4.6.3 fails to parse the following program:
template<void (*F)(void)>
struct Func {};
template<typename T>
void foo();
int main() {
struct Bar {}; // function-local type
Func<foo<Bar>> x;
}
The error is the following, on the line that declares `x` in `main`:
> error: non-template argument refers to function 'foo<Bar>' with internal
> linkage
> Func<foo<Bar>> x;
> ^~~~~~~~
I might be mistaken as I'm not very familiar with linkage, but this seems to
run afoul of n3242's ยง14.3.2:
> A template-argument for a non-type, non-template template-parameter shall be
> one of:
> [...]
> - a constant expression (5.19) that designates the address of an object with
> static storage duration and external or internal linkage or __a function with
> external or internal linkage__, including function templates and function
> template-ids but excluding non-static class members [...]
It also happens (according to this guy: http://stackoverflow.com/q/18498957/)
with Clang 3.4 (trunk 187493), although in this case it says the function "has
no linkage" (which seems to be a better reason to refuse it).
G++ will gladly compile that code.
It should also be noted that this works with clang:
template<typename T>
void foo();
int main() {
struct Bar {}; // function-local type
void (*y)() = foo<Bar>;
}
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs