[llvm-bugs] [Bug 32616] New: Document that va_arg(ap, void*) can be used to consume any pointer argument

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 11 00:29:47 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=32616

            Bug ID: 32616
           Summary: Document that va_arg(ap, void*) can be used to consume
                    any pointer argument
           Product: Documentation
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: General docs
          Assignee: unassignedbugs at nondot.org
          Reporter: cuoq at trust-in-soft.com
                CC: llvm-bugs at lists.llvm.org

The C11 standard allows to confuse void* and char* when consuming arguments
from a va_list, and only these types of pointers:

http://port70.net/~nsz/c/c11/n1570.html#7.16.1.1p2

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:

http://www.openwall.com/lists/musl/2017/04/10/3

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170411/8b7cd96a/attachment.html>


More information about the llvm-bugs mailing list