The clang compiler emit warnings for the snippet below, as can be seen here.
clang++ -std=c++14 -O0 -Wall -pedantic -pthread main.cpp && ./a.out
main.cpp:1:18: warning: braces around scalar initializer [-Wbraced-scalar-init]
void point(int = {1}, int = {2}) {}
^~~
main.cpp:1:29: warning: braces around scalar initializer [-Wbraced-scalar-init]
void point(int = {1}, int = {2}) {}
^~~
2 warnings generated.
Why is this?
void point(int = {1}, int = {2}) {}
int main(){
point();
}
As far as I can tell, {1}
and {2}
are perfectly valid default arguments according to [dcl.fct.default]/1, [dcl.fct]/3 and [dcl.init]/1.