<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 - __attribute__((callback(4))) gives confusing error message"
   href="https://bugs.llvm.org/show_bug.cgi?id=48107">48107</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__attribute__((callback(4))) gives confusing error message
          </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>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>C
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>felix-llvm@fefe.de
          </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>I am trying to use the callback attribute to annotate functions in my code.
I tried to annotate qmail in my libc header with it. Here is a minimal test
case to illustrate my problem:

typedef int pthread_t;
typedef int pthread_attr_t;
typedef unsigned long size_t;

__attribute__((callback (3, 4)))
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
                                      void *(*start_routine) (void *), void
*arg);

__attribute__((callback (4)))
void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *,
const void *));

Compiling this gives:

% clang -c y.c
y.c:9:16: error: 'callback' attribute takes no arguments
__attribute__((callback (4)))
               ^
1 error generated.


Uh, wot? I'm not sure what is happening here. As I understand the
documentation, having just one argument to callback is OK here. But I tried
putting it as (4,1) instead, but that also does not compile, with this error
message:

y.c:9:16: error: 'callback' attribute takes one argument
__attribute__((callback (4, 1)))

What is going on here?</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>