<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [analyzer] EnumCastOutOfRange false-positive for bitmasks"
   href="https://bugs.llvm.org/show_bug.cgi?id=49381">49381</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[analyzer] EnumCastOutOfRange false-positive for bitmasks
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>11.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Static Analyzer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>dcoughlin@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>balazs.benics@sigmatechnology.se
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dcoughlin@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The EnumCastOutOfRange checker emits a warning for this code:

// -std=c++17 -Xclang -analyze -Xclang
-analyzer-checker=core,alpha.cplusplus.EnumCastOutOfRange -Xclang
-analyzer-output=text
<a href="https://godbolt.org/z/xosTxq">https://godbolt.org/z/xosTxq</a>

  enum TestEnum {
    A = 0,
    B = 1,
    C = 2,
    D = 4,
  };

  void bitmasks() {
    static_assert((B | C | D) == 7);
    TestEnum t = static_cast<TestEnum>(7); // should not warn
    (void)t;
  }

The checker should recognize the bitmask and check the bounds accordingly.
/CC Endre Fülöp, the co-author of the checker</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>