我有一个小玩具程序:
static int value = 0;
int function(int &value=value) {
return value;
}
int main() {
function();
}
Run Code Online (Sandbox Code Playgroud)
使用g ++ 7.2进行编译:
g ++ -std = c ++ 11 -Wall -Wextra test.cc -o test
没问题.
用clang ++编译 - 3.9:
clang ++ - 3.9 -std = c ++ 11 -Wall -Wextra test.cc -o test
test.cc:3:25: error: default argument references parameter 'value'
int function(int &value=value) {
^~~~~
test.cc:8:5: error: no matching function for call to 'function'
function();
^~~~~~~~
test.cc:3:5: note: candidate function not …Run Code Online (Sandbox Code Playgroud)