In C++, some declarations are ambiguous.
The grammar cannot distinguish the direct-initialization style of variable definition from the declaration of a function's signature.
The below example can be read either as:
- The declaration of a variable `i` that holds the value of `n` casted into an `int`
- The declaration of a function `i` whose parameter `n` is an `int`, `int i(int n);`
```cpp
void f(double n) {
int i(int(n));
}
```
The C++ standard requires that such syntactic ambiguities are resolved by being interpreted as the latter. This is the **most vexing parse** rule.
Fortunately, Clang++ warns you that the most vexing parse has been applied.
To force the intended variable initialization, you can use:
- Extra parentheses, `int i((int(n)));`
- Copy-initialization, `int i = int(n);`
- Brace-initialization, `int i{int(n)};`