Feature or bug: implicit cast from false to 0



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?
.



Relevant Pages

  • Re: Observe wrapping variables in while loops
    ... wrapping in while loops, and was wondering if this was useful for the linux ... typedef enum bool; ... const char *func; ... int while_unsigned ...
    (Linux-Kernel)
  • Re: directories
    ... without using an API? ... Bool open dir ... int free dir ... (const char *root, const char *path); ...
    (comp.lang.c)
  • Re: Cannot convert type int to bool
    ... I don't know why you get this error but it could be related with bool values being limited to 1 or 0. ... In this case, the int is 1, but I wouldn't want the compiler trying to determine stuff like that--too much overhead. ... results in a compiler error: ... wtf, any ideas on how to work around this? ...
    (microsoft.public.dotnet.languages.csharp)
  • is this MFC? + Book recommendations?
    ... import Bool MessageBeep ... import int RegisterWindowMessage ... import HWnd SetActiveWindow ... import DWord SetForegroundWindow ...
    (microsoft.public.vc.mfc)
  • Re: is this MFC? + Book recommendations?
    ... import Bool MessageBeep ... import int RegisterWindowMessage ... import HWnd SetActiveWindow ... import DWord SetForegroundWindow ...
    (microsoft.public.vc.mfc)