<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:balazs.benics@sigmatechnology.se" title="Balazs Benics <balazs.benics@sigmatechnology.se>"> <span class="fn">Balazs Benics</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - alpha.core.BoolAssignment does not work (at least for C and C++)"
   href="https://bugs.llvm.org/show_bug.cgi?id=52296">bug 52296</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>INVALID
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>REOPENED
           </td>
           <td>RESOLVED
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - alpha.core.BoolAssignment does not work (at least for C and C++)"
   href="https://bugs.llvm.org/show_bug.cgi?id=52296#c3">Comment # 3</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - alpha.core.BoolAssignment does not work (at least for C and C++)"
   href="https://bugs.llvm.org/show_bug.cgi?id=52296">bug 52296</a>
              from <span class="vcard"><a class="email" href="mailto:balazs.benics@sigmatechnology.se" title="Balazs Benics <balazs.benics@sigmatechnology.se>"> <span class="fn">Balazs Benics</span></a>
</span></b>
        <pre>It seems like the corresponding AST looks like this:
    |-DeclStmt <line:6:3, col:16>
    | `-VarDecl <col:3, col:15> col:8 foo 'BOOL':'int' cinit
    |   `-UnaryOperator <col:14, col:15> 'int' prefix '-'
    |     `-IntegerLiteral <col:15> 'int' 1
    |-DeclStmt <include/stdbool.h:20:15, line:7:17>
    | `-VarDecl include/stdbool.h:20:15, line:7:16> col:9 bar 'bool' cinit
    |   `-ImplicitCastExpr <col:15, col:16> 'bool' <IntegralToBoolean>
    |     `-UnaryOperator <col:15, col:16> 'int' prefix '-'
    |       `-IntegerLiteral <col:16> 'int' 1
    `-DeclStmt <line:8:3, col:16>
      `-VarDecl <col:3, col:15> col:8 qaz 'bool' cinit
        `-ImplicitCastExpr <col:14, col:15> 'bool' <IntegralToBoolean>
          `-UnaryOperator <col:14, col:15> 'int' prefix '-'
            `-IntegerLiteral <col:15> 'int' 1

And, by calling the `getType()->isUnsignedIntegerOrEnumerationType()` on the
`ImplicitCastExpr` nodes, I get `true`.
This suggests to me that the behavior is actually correct, and the implicit
conversion transforms `-1` into `1` according to the C++ language rules.
As a result, `bar` and `qaz` are actually initialized to `true`.

That being said, we should probably extend the checker documentation to
highlight this behavior.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>