[PATCH] D38132: [Support] mapped_file_region: avoid tautological comparison.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 21 08:00:28 PDT 2017


If someone is passing a uint64 when size_t is already smaller than uint64,
that already seems like a bug, which the user should fix at compile time
with an explicit cast.  It seems like preprocessor logic here is trying to
turn a compile time problem into a runtime problem.  Feel free to wait for
other opinions but personally I'd at *least* assert instead of just
returning an error code

On Thu, Sep 21, 2017 at 7:36 AM Roman Lebedev via Phabricator <
reviews at reviews.llvm.org> wrote:

> lebedev.ri added a comment.
>
> On Thu, Sep 21, 2017 at 5:25 PM, Zachary Turner <zturner at google.com>
> wrote:
>
> > No, I just fail. I somehow thought the check was against the Offset
> >  parameter.
> >
> > Is changing the function to take a size_t an option?
>
> We certainly could do that. But then, if `size_t` is *not* as large as
> `uint64_t`,
> when someone passes `uint64_t` value into the constructor, it will be
> either
> silently truncated, or there will only be a compile-time warning about
> truncation...
> I'd say that is worse than this preprocessor magic?
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D38132
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170921/8211bf85/attachment.html>


More information about the llvm-commits mailing list