I have a little toy program:
static int value = 0;
int function(int &value=value) {
return value;
}
int main() {
function();
}
Compiling with g++ 7.2:
g++ -std=c++11 -Wall -Wextra test.cc -o test
No problem.
Compiling with 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 viable: requires single argument 'value', but no arguments were provided
int function(int &value=value) {
^
2 errors generated.
Kaboom. Who's right?