Re:Analog Devices Expands over 1000 Linux Device Drivers to ...
by CamperBob2 on Monday December 06, 2021 @12:44AM
(#29456571)
That reminds me of one of my favorite footguns:
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.