<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 - alpha.deadcode.UnreachableCode can't be disabled for unreachable-asserts"
   href="https://bugs.llvm.org/show_bug.cgi?id=34700">34700</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>alpha.deadcode.UnreachableCode can't be disabled for unreachable-asserts
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>kremenek@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>tss@iki.fi
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>My code marks supposedly-unreachable code paths with i_unreached(), which is a
macro expanding to my own assert-like function marked with
__attribute__((noreturn)). It would be nice if clang didn't complain that these
i_unreached() code paths are unreachable, because that's intentional. I tried
defining it out for scan-builds, but that results in even more (and scarier)
false positives, because clang doesn't always understand that some of the
unreachable code paths really are unreachable.

Perhaps code paths that end up in a function marked with noreturn attribute
shouldn't be complained about? Or a new __attribute__((unreachable)) could be
created?

Simple test demonstrating the problem:

#include <stdlib.h>
#define i_unreached() abort()
int main(void)
{
        int a = 1;
        if (a == 1) return 0;
        i_unreached();
}

% scan-build -o scan-build -enable-checker alpha.deadcode.UnreachableCode clang
test2.c -o test
scan-build: Using '/usr/local/bin/clang' for static analysis
test2.c:7:2: warning: This statement is never executed
        i_unreached();
        ^~~~~~~~~~~~~</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>