<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - implicit _Noreturn"
   href="http://llvm.org/bugs/show_bug.cgi?id=20301">20301</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>implicit _Noreturn
          </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>Linux
          </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>Static Analyzer
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>dilyan.palauzov@aegee.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I have compiled llvam/clang based on today's trunk.

When I compile this program

  #include <stdlib.h>
  #include <string.h>
  #include <stdio.h>

  static void z() {
    exit(0);
  }

  int main(__attribute__((unused)) int argc, char** argv) {
    int a;
    if (strlen(argv[1]) < 3 || sscanf(argv[1], "%i", &a) < 1)
        z();
    if (a > 0) printf("A");
  }

with
clang -std=c11 -Weverything unitialized-noreturn.c 2> unitialized-error

I get
unitialized-noreturn.c:5:17: warning: function 'z' could be declared with
attribute 'noreturn' [-Wmissing-noreturn]
static void z() {
                ^
unitialized-noreturn.c:11:7: warning: variable 'a' is used uninitialized
whenever '||' condition is true [-Wsometimes-uninitialized]
  if (strlen(argv[1]) < 3 || sscanf(argv[1], "%i", &a) < 1)
      ^~~~~~~~~~~~~~~~~~~
unitialized-noreturn.c:13:7: note: uninitialized use occurs here
  if (a > 0) printf("A");
      ^
unitialized-noreturn.c:11:7: note: remove the '||' if its condition is always
false
  if (strlen(argv[1]) < 3 || sscanf(argv[1], "%i", &a) < 1)
      ^~~~~~~~~~~~~~~~~~~~~~
unitialized-noreturn.c:10:8: note: initialize the variable 'a' to silence this
warning
  int a;
       ^
        = 0
2 warnings generated.

However, when I put _Noreturn on line 5, right before the definition of
function z() I get no warnings and no notes.

Provided that clang correctly detects the noreturn-nature of z(), why isn't
_Noreturn implied, but has to be provided explicitly?  I see _Noreturn as a way
to hint the compiler (e.g. in (forward) declaration) that a function does not
return, which only necessary when the compiler cannot determine this on its
own.

Why does the second note ("||") depend on _Noreturn?

I expect that clang puts implicit _Noreturn to z() and that the ||-note does
not depend on _Noreturn.</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>