diff options
author | Martin Storsjö <martin@martin.st> | 2021-06-01 09:04:58 +0000 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2021-06-04 12:07:30 +0300 |
commit | b0cc7b53a53f180c0b70b8b2f02999be78a32395 (patch) | |
tree | 6d476bdc01699c69d9b3d93c7b7f6d43ff6c36ac /flang/lib/Frontend/CompilerInvocation.cpp | |
parent | aec9cbbeb863dbd3ea362f99eb8b84dfbdb568a2 (diff) | |
download | llvm-b0cc7b53a53f180c0b70b8b2f02999be78a32395.zip llvm-b0cc7b53a53f180c0b70b8b2f02999be78a32395.tar.gz llvm-b0cc7b53a53f180c0b70b8b2f02999be78a32395.tar.bz2 |
[libcxx] Don't use an undefined '+' in unsigned/octal/hexal print formats
If building code like this:
unsigned long val = 1000;
snprintf(buf, sizeof(buf), "%+lu", val);
with clang, clang warns
warning: flag '+' results in undefined behavior with 'u' conversion specifier [-Wformat]
Therefore, don't construct such undefined format strings. (There's
no compiler warnings here, as the compiler can't inspect dynamically
assembled format strings.)
This fixes number formatting in mingw-w64 if built with
`__USE_MINGW_ANSI_STDIO` defined (there, the '+' flag causes a
leading plus to be printed when formatting unsigned numbers too,
while the '+' flag doesn't cause any extra leading plus in other
stdio implementations).
Differential Revision: https://reviews.llvm.org/D103444
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions