diff options
author | A. Jiang <de34@live.cn> | 2025-05-13 04:49:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-12 16:49:25 -0400 |
commit | ab60910e01eaa8bcf993cdb59a95f882b3859fd1 (patch) | |
tree | 836029e7523ea2d6d08a67f0e255c00e6990c435 /clang/lib/Serialization/ModuleManager.cpp | |
parent | fa985b5f1e3db76e5f52dec41c2100cb354c771a (diff) | |
download | llvm-ab60910e01eaa8bcf993cdb59a95f882b3859fd1.zip llvm-ab60910e01eaa8bcf993cdb59a95f882b3859fd1.tar.gz llvm-ab60910e01eaa8bcf993cdb59a95f882b3859fd1.tar.bz2 |
[libc++][format] Discard contents since null-terminator in character arrays in formatting (#116571)
Currently, built-in `char`/`wchar_t` arrays are assumed to be
null-terminated sequence with the terminator being the last element in
formatting. This doesn't conform to [format.arg]/6.9.
> otherwise, if `decay_t<TD>` is `char_type*` or `const char_type*`,
> initializes value with `static_cast<const char_type*>(v)`;
The standard wording specifies that character arrays are decayed to
pointers. When the null terminator is not the last element or there's no
null terminator (the latter case is UB), libc++ currently produces
different results.
Also fixes and hardens `formatter<CharT[N], CharT>::format` in
`<__format/formatter_string.h>`. These specializations are rarely used.
Fixes #115935. Also checks the preconditions in this case, which fixes
#116570.
Diffstat (limited to 'clang/lib/Serialization/ModuleManager.cpp')
0 files changed, 0 insertions, 0 deletions