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: unassignedb...@nondot.org
Reporter: c...@trust-in-soft.com
CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs