Can someone enlighten me what is going wrong with this code:
template<typename S, typename T = int>
void foo() {
extern int x;
}
Error message with GCC 5.5 and --std=c++11:
test.cpp: In function 'void foo()':
test.cpp:4:16: error: default argument for template parameter for class enclosing 'x'
extern int x;
^
However, Clang 3.8 compiles the same code successfully.
For this very simple sample, there's a workaround putting the extern declaration out of function. But for the actual code, the extern declaration must be in foo scope, so the workaround is not available.
I search with Google and find a GCC bug reported 7 years ago and still opened. I'm not sure if I get the same bug