It was an accidental typo that snuck in that I missed.  it was suppose to be "int" and I thought I had changed it back.

thanks

Andrew


PS.  And this is only called if mask is != 0,   but point taken, we should guard the routine inside for future proofing.  Ill take care of it monday.

On 6/21/25 10:14, Jakub Jelinek wrote:
On Tue, Jun 17, 2025 at 09:27:27PM -0400, Andrew MacLeod wrote:
+  uint z = wi::ctz (m_bitmask.mask ());
uint is some compatibility type in glibc sys/types.h enabled in misc/GNU
modes, so it doesn't exist on many hosts.
Furthermore, wi::ctz returns int rather than unsigned and the var is
only used in comparison to zero or as second argument of left shift, so
I think just using int instead of unsigned is better.

Committed as obvious to trunk.

BTW, if nothing guards irange::snap from being called when
m_bitmask.mask () == 0, I'm afraid there is compile time UB, because
in that case wi::ctz returns the precision of the wide_int and then
there is a left shift of wide_int with the same precision by that amount.

2025-06-21  Jakub Jelinek  <ja...@redhat.com>

        PR middle-end/120746
        * value-range.cc (irange::snap): Use int type instead of uint.

--- gcc/value-range.cc.jj       2025-06-21 16:03:56.922820186 +0200
+++ gcc/value-range.cc  2025-06-21 16:05:28.167610429 +0200
@@ -2287,7 +2287,7 @@ bool
  irange::snap (const wide_int &lb, const wide_int &ub,
              wide_int &new_lb, wide_int &new_ub)
  {
-  uint z = wi::ctz (m_bitmask.mask ());
+  int z = wi::ctz (m_bitmask.mask ());
    if (z == 0)
      return false;

        Jakub


Reply via email to