digitalmars.D.bugs - [Issue 2172] New: bool add bool accepted?
- d-bugmail puremagic.com (20/20) Jun 25 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2172
- d-bugmail puremagic.com (11/11) Jun 27 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2172
- Jarrett Billingsley (12/24) Jun 27 2008 I can understand the OP's confusion.
- d-bugmail puremagic.com (5/5) Jun 27 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2172
- d-bugmail puremagic.com (16/16) Jun 29 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2172
- d-bugmail puremagic.com (14/14) Jan 29 2012 http://d.puremagic.com/issues/show_bug.cgi?id=2172
- d-bugmail puremagic.com (12/12) Jan 30 2012 http://d.puremagic.com/issues/show_bug.cgi?id=2172
- d-bugmail puremagic.com (11/11) Jan 30 2012 http://d.puremagic.com/issues/show_bug.cgi?id=2172
http://d.puremagic.com/issues/show_bug.cgi?id=2172 Summary: bool add bool accepted? Product: D Version: 1.030 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: davidl 126.com BugsThisDependsOn: 1511 bool t; t= true+false; // this accepted t= true+true; // Error: cannot implicitly convert expression (2) of type int to bool bool type shouldn't be addable. and error message is confusing. --
Jun 25 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2172 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID 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. --
Jun 27 2008
<d-bugmail puremagic.com> wrote in message news:g43oq2$2k82$1 digitalmars.com...http://d.puremagic.com/issues/show_bug.cgi?id=2172 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID 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.
Jun 27 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2172 I think the confusion comes from the cast failure being value dependent rather than just type dependent. --
Jun 27 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2172 davidl 126.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID | I don't think we still need to keep consistent with C on that exactly point. Compiler can at least giving a waring on this. And adding code to BinExp::semantic , and provide a table like implicitconv table [op, e1->type, e2->type] mapping to bin op allow for TOK.TOKadd, bool, bool -> false TOK.TOKmul, bool, bool -> false and this naturally fix issue 1511 --
Jun 29 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2172 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yebblies gmail.com Platform|x86 |All Version|1.030 |D1 & D2 Summary|bool add bool accepted? |statically disallow bool + | |bool OS/Version|Windows |All Severity|normal |enhancement -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 29 2012
http://d.puremagic.com/issues/show_bug.cgi?id=2172 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc The error message looks clear. And and this point I don't think D boolean semantics will change. So I think this bug report needs to be closed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 30 2012
http://d.puremagic.com/issues/show_bug.cgi?id=2172 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution| |FIXED I tend to agree. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 30 2012