To test:
void Fun(int) {}
int main() {
unsigned a(-1);
Fun({a});
}
Before:
$ clang++ -Wbraced-scalar-init -Wc++11-narrowing -std=c++17 /tmp/1.cpp -o /tmp/exe
/tmp/1.cpp:4:10: error: non-constant-expression cannot be narrowed from type 'unsigned int' to 'int' in initializer list [-Wc++11-narrowing]
Fun({a});
^
/tmp/1.cpp:4:10: note: insert an explicit cast to silence this issue
Fun({a});
^
static_cast<int>( )
/tmp/1.cpp:4:9: warning: braces around scalar initializer [-Wbraced-scalar-init]
Fun({a});
^~~
1 warning and 1 error generated.
After:
$ clang++ -Wno-braced-scalar-init -Wc++11-narrowing -std=c++17 /tmp/1.cpp -o /tmp/exe
/tmp/1.cpp:4:10: error: non-constant-expression cannot be narrowed from type 'unsigned int' to 'int' in initializer list [-Wc++11-narrowing]
Fun({a});
^
/tmp/1.cpp:4:10: note: insert an explicit cast to silence this issue
Fun({a});
^
static_cast<int>( )
1 error generated.