<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>From a C perspective this makes perfect sense as there is no "bool" types, if statements branch based on a value not being zero rather than not being logically true. </div><div><br></div><div>From a C++ perspective, where the typing is more strict, I have copied this bit from the Microsoft C++ site which was the first thing I could find on the subject and I assume is standard conforming:</div><div><br></div><div><span style="background-color: rgba(255, 255, 255, 0);">The <span class="input" style="font-weight: 700;">bool</span> type participates in integral promotions. An r-value of type <span class="input" style="font-weight: 700;">bool</span> can be converted to an r-value of type <span class="input" style="font-weight: 700;">int</span>, with <strong>false</strong> becoming zero and <strong>true</strong> becoming one. As a distinct type, <span class="input" style="font-weight: 700;">bool</span> participates in overload resolution.</span><br><br></div><div><br>On Feb 6, 2015, at 10:19 AM, Guy Maurel <<a href="mailto:guy.maurel@kde.org">guy.maurel@kde.org</a>> wrote:<br><br></div><blockquote type="cite"><div><span>Hello!</span><br><span></span><br><span>Let say: </span><br><span> int a = 5;</span><br><span> int b = 7;</span><br><span> int i = 20;</span><br><span> if ((a == b) + i) {</span><br><span> a = 15;</span><br><span> }</span><br><span>My question is:</span><br><span>The expression (a == b) gives a bool result.</span><br><span>Why is it allowed to add a "bool" and an "int".</span><br><span></span><br><span>Thanks</span><br><span>-- </span><br><span>Guy Maurel</span><br><span>_______________________________________________</span><br><span>cfe-dev mailing list</span><br><span><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a></span><br><span><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a></span><br></div></blockquote></body></html>