<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 - Document that va_arg(ap, void*) can be used to consume any pointer argument"
   href="https://bugs.llvm.org/show_bug.cgi?id=32616">32616</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Document that va_arg(ap, void*) can be used to consume any pointer argument
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Documentation
          </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>General docs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>cuoq@trust-in-soft.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The C11 standard allows to confuse void* and char* when consuming arguments
from a va_list, and only these types of pointers:

<a href="http://port70.net/~nsz/c/c11/n1570.html#7.16.1.1p2">http://port70.net/~nsz/c/c11/n1570.html#7.16.1.1p2</a>

As explained by Rich Felker as part of a discussion on musl's scanf
implementation, this makes it very inconvenient to implement POSIX's positional
specifiers for scanf. Clearly the intent of POSIX's “all the leading arguments,
from the first to the (N-1)th, are pointers” is to allow these arguments to be
consumed on the spot when %N$ is encountered:

<a href="http://www.openwall.com/lists/musl/2017/04/10/3">http://www.openwall.com/lists/musl/2017/04/10/3</a>

Since the open-source world divides the C compilation platform described by the
C standard into C compilers (Clang, GCC) and standard libraries (Glibc, musl,
...), with the implementation of varargs on the compiler side and the
implementation of scanf on the standard library side, it would make sense to
document that on target platforms where the representation of pointers is
uniform, the compilers allow va_arg(ap, void*) to consume any pointer argument.</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>