shafik added inline comments.
================
Comment at:
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp:762
+static void fill_clamp(T &dest, U src, typename T::value_type fallback) {
+ dest = src <= std::numeric_limits<typename T::value_type>::max() ? src
+ : fallback;
----------------
mgorny wrote:
> shafik wrote:
> > I am building on a macOS and I seeing the following diagnostic for this
> > line:
> >
> > ```
> > warning: comparison of integers of different signs: 'int' and
> > 'std::numeric_limits<unsigned int>::type' (aka 'unsigned int')
> > [-Wsign-compare]
> > dest = src <= std::numeric_limits<typename T::value_type>::max() ? src
> > ~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > ```
> >
> > and it is triggered by:
> >
> > ```
> > fill_clamp(data.gdb_st_dev, file_stats.st_dev, 0);
> > ```
> >
> > In this case it will do the right thing but allowing mixed types is
> > problematic, usually I see clamp done with homogeneous types.
> Could you suggest how to fix it? Some platforms have different signedness
> than the GDB struct type.
Since we don't have C++20 I think you would have to roll your own `cmp_less`
see the [possible implementation on
cppreference](https://en.cppreference.com/w/cpp/utility/intcmp).
For reference see [Safe integral comparisons
proposal](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0586r2.html).
I looked and I don't see something similar in llvm anywhere but I could be
missing it.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D107840/new/
https://reviews.llvm.org/D107840
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits