diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -13363,6 +13363,13 @@ if (InRange && IsEnumConstOrFromMacro(S, Constant)) return false; + // Don't warn if the comparison involves the 'size_t' type. + QualType SizeT = S.Context.getSizeType(); + if (S.Context.hasSameType(Constant->getType().getCanonicalType(), SizeT) && + S.Context.hasSameType(Other->getType().getCanonicalType(), SizeT)) { + return false; + } + // A comparison of an unsigned bit-field against 0 is really a type problem, // even though at the type level the bit-field might promote to 'signed int'. if (Other->refersToBitField() && InRange && Value == 0 &&