[Issue 2172] bool add bool accepted?

Jarrett Billingsley kb3ctd2 at yahoo.com
Fri Jun 27 15:38:34 PDT 2008


<d-bugmail at puremagic.com> wrote in message 
news:g43oq2$2k82$1 at digitalmars.com...
> http://d.puremagic.com/issues/show_bug.cgi?id=2172
>
>
> bugzilla at digitalmars.com changed:
>
>           What    |Removed                     |Added
> ----------------------------------------------------------------------------
>             Status|NEW                         |RESOLVED
>         Resolution|                            |INVALID
>
>
>
>
> ------- Comment #1 from bugzilla at digitalmars.com  2008-06-27 17:15 -------
> bool follows the same integral promotion rules that C has, and this is 
> working
> as designed. I also do not understand why the error message is confusing - 
> 2
> cannot be implicitly converted to bool, as it says.

I can understand the OP's confusion.

http://www.digitalmars.com/d/1.0/type.html

"The only operators that can accept operands of type bool are: & | ^ &= |= 
^= ! && || ?:. A bool value can be implicitly converted to any integral 
type, with false becoming 0 and true becoming 1."

Which one is it?  It seems that promotion to an int makes the first rule 
unnecessary.

Also, keep in mind that D *is* your language and you don't *have* to do 
everything the same way as C.  I think that having boolean types not 
implicitly convertible to ints makes a lot more sense. 




More information about the Digitalmars-d-bugs mailing list