<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 - Erroneous -Wunreachable-code in some cases when C++20 `[[likely]]`/`[[unlikely]]` are used."
   href="https://bugs.llvm.org/show_bug.cgi?id=49425">49425</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Erroneous -Wunreachable-code in some cases when C++20 `[[likely]]`/`[[unlikely]]` are used.
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

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

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>C++2a
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ian@geometrian.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider the following simple, complete example:

    //Compile with "-std=c++20 -Wunreachable-code -O3"
    bool foo();
    int  bar() {
        if (foo()) [[likely]] return 1;
        else                  return 0;
    }

The compiler of course cannot tell what `foo()` returns in this translation
unit.  However, clang (tested 13.0.0) complains:

    <source>:4:13: warning: code will never be executed [-Wunreachable-code]
            if (foo()) [[likely]] return 1;
                       ^~~~~~~~~~~~~~~~~~~

This is an incorrect claim.  Note that the generated code is correct, and in
particular the positive branch is correctly implemented.  Removing `[[likely]]`
also removes the warning (which makes no sense since `[[likely]]` is a hint);
the generated code in that case happens to be the same.</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>