The posix standard defines an alternate mode for printf where the
conversions also have an index that describes which argument to select.
Due to how variadic arguments work in C, to reach the nth argument all
n-1 previous arguments must be read with their correct types. If the
format string does not specify the types for a continuous set of
arguments, then the arguments after the discontinuity cannot be safely
read. This patch causes all conversions requesting an argument that
comes after a gap be treated as raw (i.e. the conversion string is
printed literally).
Details
Details
- Reviewers
sivachandra lntue - Commits
- rGbf279f903b3f: [libc] Prevent printf index mode crashes
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
Mostly LGTM but I left a style comment inline.
libc/src/stdio/printf_core/parser.cpp | ||
---|---|---|
39–46 | Readers would expect that a macro named GET_<> would be used a function macro which returns something. That aside, can this macro be replaced by a lambda? |
Comment Actions
rename macro
libc/src/stdio/printf_core/parser.cpp | ||
---|---|---|
39–46 | I don't think this macro can be replaced by a lambda because it needs to also take a type, and templating lambdas is a C++20 feature from what I can tell. |
Readers would expect that a macro named GET_<> would be used a function macro which returns something. That aside, can this macro be replaced by a lambda?