[PATCH] D159138: [clang][Sema] Fix format size estimator's handling of %o, %x, %X with alternative form
Nick Desaulniers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 31 08:37:18 PDT 2023
nickdesaulniers added inline comments.
================
Comment at: clang/test/Sema/warn-fortify-source.c:100-102
+ __builtin_snprintf(buf, 2, "%#x", n);
+ __builtin_snprintf(buf, 2, "%#X", n);
+ __builtin_snprintf(buf, 2, "%#o", n);
----------------
Note that GCC -Wformat-truncation can warn on some of these.
https://godbolt.org/z/jE3axWe1W
Looks like the diagnostic keeps an up and lower bounds on the estimated format string expansion.
Trunk for Clang also warns for these, so is this change a regression? Or are both GCC and Clang (trunk) incorrect?
================
Comment at: clang/test/Sema/warn-fortify-source.c:121-123
+ __builtin_vsnprintf(buf, 2, "%#x", list);
+ __builtin_vsnprintf(buf, 2, "%#X", list);
+ __builtin_vsnprintf(buf, 2, "%#o", list);
----------------
Clang @ trunk and GCC both warn for these 3. Regression?
https://godbolt.org/z/j551hTE5E
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D159138/new/
https://reviews.llvm.org/D159138
More information about the cfe-commits
mailing list