[PATCH] D39263: [support] remove tautological comparison in Support/Windows/Path.inc

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 25 09:00:22 PDT 2017


I don’t think the check is even useful in any form. The win32 api can
handle 64 bit inputs for size and offset — always. The size of the argument
to the llvm function is irrelevant
On Wed, Oct 25, 2017 at 8:55 AM Reid Kleckner via Phabricator <
reviews at reviews.llvm.org> wrote:

> rnk added inline comments.
>
>
> ================
> Comment at: llvm/lib/Support/Windows/Path.inc:726
> -  if (Size > std::numeric_limits<SIZE_T>::max())
> -    return make_error_code(errc::invalid_argument);
> -
> ----------------
> amccarth wrote:
> > I assume someone was originally worried that `SIZE_T` would be 32 bits
> wide in a 32-bit build but somehow believed `std::size_t` (which is the
> type of Size) could still somehow be larger than that.  Ain't gonna happen.
> I wonder if we should turn these examples of dynamic range checks into
> static_asserts. We saw a lot of these tautological comparison warnings in
> Chrome, where it was much less obvious that the types are the same size.
> Would this be an appropriate replacement for the check?
>   static_assert(std::numeric_limits<decltype(Size)>::max() <=
>                 std::numeric_limits<SIZE_T>::max());
>
>
> https://reviews.llvm.org/D39263
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171025/1c333b69/attachment.html>


More information about the llvm-commits mailing list