On Thu, Aug 11, 2022 at 3:04 PM Nick Desaulniers <ndesaulniers@xxxxxxxxxx> wrote: > > Yeah, I guess adding a truncate to the caller is kind of unnecessary > if you're still going to use %hhd anyways. What are your thoughts on > this bug I've filed? > https://github.com/llvm/llvm-project/issues/57102 I really wish that bug report was about how *wrong* it is to warn about that thing. Sure, a cast adds pointless code to the caller, and is overhead, but that isn't really the argument here. The argument really is that "if you force the value to always be a char, then %hhd is pointless" Basically, %hhu and %hhd simply do not make sense if you always require the value to be cast to the right range, because for those cases the much simpler and more straightforward %d and %u already work. So a warning that says "you didn't cast it to the rigth range" is truly fundamentally broken. So it's not about "a cast generates worse code". It's really about "that warning is WRONG". Linus