void foo(bool bar)
{
}
int main(void)
{
foo("Whose bright idea was this?");
}
No error, not even a warning, perfectly legit code. If bar had been declared int or char, you'd get an error. Instead, your code ends up less safe because you used bool, thinking you were doing the right thing. Yes, they wanted to allow it anywhere a conditional expression would fit, but implicit conversion from anything other than int and char would have been a good place to draw the line.
So I wouldn't be surprised if the GP example was prompted by a similar design flaw in either the language or a particular compiler.
So I wouldn't be surprised if the GP example was prompted by a similar design flaw in either the language or a particular compiler.