<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 - Inconsistent (missing) incompatible function pointer type warnings"
   href="https://bugs.llvm.org/show_bug.cgi?id=42120">42120</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Inconsistent (missing) incompatible function pointer type warnings
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>C
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>bruno-llvm@defraine.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang marks pointer conversions that add "noreturn" or "noescape" information
to function types as incompatible (while removing such information is fine),
but this warning is not consistent:

$ cat test.c

void fun00(int *);
void fun01(int *) __attribute__((noreturn));
void fun10(__attribute__((noescape)) int *);
void fun11(__attribute__((noescape)) int *) __attribute__((noreturn));

// OK: safe, no warning
void (*fptr01)(int *) = &fun01;
void (*fptr02)(__attribute__((noescape)) int *) = &fun11;
void (*fptr03)(int *) __attribute__((noreturn)) = &fun11;

// OK: unsafe, warning
void (*fptr11)(int *) __attribute__((noreturn)) = &fun00;
void (*fptr12)(__attribute__((noescape)) int *) = &fun00;
void (*fptr13)(__attribute__((noescape)) int *) __attribute__((noreturn)) =
&fun00;

// NOT OK: also unsafe, no warning?
void (*fptr14)(__attribute__((noescape)) int *) = &fun01;
void (*fptr15)(int *) __attribute__((noreturn)) = &fun10;

$ clang -c -x c test.c
(only cases fptr11, fptr12, fptr13 are warnings; fptr14 and fptr15 pass without
warning/error)

Godbolt: <a href="https://godbolt.org/z/XjFsFB">https://godbolt.org/z/XjFsFB</a>

That no warnings are issued for fptr14 and fptr15 cases seems wrong. The
conversions are at least as dangerous as the fptr11 and fptr12 cases, which do
get warnings.

Note that C++ behavior:

$ clang -c -x c++ test.c
(cases fptr11, fptr12, fptr12, fptr13, fptr14, fptr15 are flagged as errors)

Godbolt: <a href="https://godbolt.org/z/cVjcCQ">https://godbolt.org/z/cVjcCQ</a></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>