Re: Feature or bug: implicit cast from false to 0




"Mihajlo Cvetanoviæ" <mac@xxxxxxxxxxxxxxxxxx> skrev i meddelandet
news:OKA5sFcmFHA.3544@xxxxxxxxxxxxxxxxxxxxxxx
> Observe this code (VC7.1):
>
> void Test(const char*)
> {
> }
>
> int main(void)
> {
> Test( false ); // OK
> Test( true ); // error C2664: cannot convert from bool to const
> char*
> }
>
> Shouldn't the first call also produce the compiler error?


No - false, 0, NULL, 1 - 1, etc are all examples of constant integral
expressions, that can be used as the null pointer value.


Test(false) works just as well as Test(0) or Test(NULL).


Bo Persson


.



Relevant Pages