<div dir="ltr">A real issue against disallowing 0/1 to bool conversion is in the translation code from C/C++ to D.<br><div><br></div><div style>For example, old C code may have thus macro constant.</div><div style>#define FALSE 0</div>
<div style>#define TRUE 1</div><div style>#define BOOL  int</div><div style>void foo(BOOL flag);</div><div style>foo(FALSE);<br></div><div style><br></div><div style>Translating the code to D:</div><div style><div>enum FALSE = 0;</div>
<div>enum TRUE = 1;<br></div><div>alias BOOL = int;</div><div>void foo(BOOL flag);</div><div>foo(FALSE);<br></div><div><br></div><div style>And then, we can misuse FALSE and TRUE.</div><div style><br></div><div style>void bar(bool flag);</div>
<div style>bar(FALSE);   // int argument FALSE(==0) now matches to bool</div><div><br></div><div><div>This is enough realistic case. We already have an actual case in core.sys.windows.windows:</div></div><div><div><br></div>
<div>    enum : int</div><div>    {</div><div>        FALSE = 0,</div><div>        TRUE = 1,</div><div>    }</div></div><div style><br></div><div style>And core sys windows.stacktrace:</div><div style><div><br></div><div>
    if (!dbghelp.SymInitialize(hProcess, generateSearchPath().ptr, TRUE))</div><div>        return;</div><div><div>(dbghelp.SymInitialize is a function pointer that defined as</div><div>    alias BOOL         function(HANDLE hProcess, PCSTR UserSearchPath, bool fInvadeProcess) SymInitializeFunc;</div>
</div><div><br></div><div><div>    struct DbgHelp</div><div>    {</div><div>        SymInitializeFunc        SymInitialize;</div></div><div>        ...</div><div>    }</div><div>)</div><div><br></div><div style>If we change the behavior, we should accept the existing code break.</div>
<div style><br></div><div style>Kenji Hara</div></div></div></div>