Skip to content

Commit ebf2e7d

Browse files
committed
Auto merge of #38223 - rkruppe:llvm-stringref-fixes, r=alexcrichton
printf type correctness The `%.*s` format specifier requires an int for the maximum size, but StringRef::size is a size_t cc @shepmaster
2 parents fa45d0b + f58e553 commit ebf2e7d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/rustllvm/PassWrapper.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,11 @@ LLVMRustPrintPasses() {
533533
StringRef PassArg = info->getPassArgument();
534534
StringRef PassName = info->getPassName();
535535
if (!PassArg.empty()) {
536-
printf("%15.*s - %.*s\n", PassArg.size(), PassArg.data(),
537-
PassName.size(), PassName.data());
536+
// These unsigned->signed casts could theoretically overflow, but
537+
// realistically never will (and even if, the result is implementation
538+
// defined rather plain UB).
539+
printf("%15.*s - %.*s\n", (int)PassArg.size(), PassArg.data(),
540+
(int)PassName.size(), PassName.data());
538541
}
539542
#else
540543
if (info->getPassArgument() && *info->getPassArgument()) {

0 commit comments

Comments
 (0)