This minimal patch allows "../gcc/configure --enable-checking=rtl" to
survive "make bootstrap" (for me on x86_64-pc-linux-gnu). Curiously
"--enable-checking=all" builds just fine.
The failure mode is:
In file included from ../../gcc/gcc/coretypes.h:479,
from ../../gcc/gcc/gimple-ssa-warn-access.cc:26:
In member function 'long int* wide_int_storage::write_val(unsigned int)',
inlined from 'void wi::copy(T1&, const T2&) [with T1 = wide_int_storage;
T2 = generic_wide_int<wide_int_ref_storage<true, false> >]' at
../../gcc/gcc/wide-int.h:2187:37,
inlined from 'wide_int_storage& wide_int_storage::operator=(const T&)
[with T = wi::hwi_with_prec]' at ../../gcc/gcc/wide-int.h:1247:12,
inlined from 'generic_wide_int<storage>&
generic_wide_int<T>::operator=(const T&) [with T = wi::hwi_with_prec;
storage = wide_int_storage]' at ../../gcc/gcc/wide-int.h:1002:23,
inlined from 'void irange_bitmask::set_unknown(unsigned int)' at
../../gcc/gcc/value-range.h:185:27,
inlined from 'virtual void irange::set_varying(tree)' at
../../gcc/gcc/value-range.h:1245:25,
inlined from 'int_range<N, RESIZABLE>::int_range(tree) [with unsigned
int N = 3; bool RESIZABLE = true]' at ../../gcc/gcc/value-range.h:1207:15,
inlined from 'bool {anonymous}::memmodel_to_uhwi(tree, gimple*, long
unsigned int*)' at ../../gcc/gcc/gimple-ssa-warn-access.cc:2870:41:
../../gcc/gcc/wide-int.h:1272:73: error: 'rng.int_range<3,
true>::<unnamed>.irange::m_bitmask.irange_bitmask::m_value.generic_wide_int<
wide_int_storage>::<unnamed>.wide_int_storage::u.wide_int_storage::<unnamed
union>::valp' may be used uninitialized [-Werror=maybe-uninitialized]
1272 | return UNLIKELY (precision > WIDE_INT_MAX_INL_PRECISION) ? u.valp
: u.val;
|
^~~
../../gcc/gcc/gimple-ssa-warn-access.cc: In function 'bool
{anonymous}::memmodel_to_uhwi(tree, gimple*, long unsigned int*)':
../../gcc/gcc/gimple-ssa-warn-access.cc:2870:21: note: 'rng' declared here
2870 | int_range_max rng (TREE_TYPE (ord));
| ^~~
Or to summarize, irange contains a member field called m_bitmask that
doesn't explicitly get initialized, and (only) with flag_checking irange
frequently calls verify_mask to ensure that m_bitmask's m_value and m_mask
fields contain sensible values. The solution is for irange's constructor
to explicitly call the irange_bitmask constructor for its m_bitmask member.
The one tiny wrinkle is that this requires the type's precision, which can
be solved by adding a second constructor that specifies the precision,
allowing int_range_max's constructor (aka int_range's constructor) to
pass along the appropriate precision to irange_bitmask's constructor.
Hopefully, that all makes sense. Tested with make bootstrap following
configure --enable-checking=rtl on x86_64-pc-linux-gnu. Ok for mainline?
2026-10-07 Roger Sayle <[email protected]>
gcc/ChangeLog
* value-range.h (irange::irange): Add a second constructor that
takes an explicit type precision. In this new constructor,
initialize m_bitmask with the specified precision.
(int_range<unigned,bool>::int_range(tree)): Use the new
constructor for irange using the type's TYPE_PRECISION.
Thanks in advance,
Roger
--
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 290ea4bb83c..5ac5f395adf 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -346,6 +346,7 @@ protected:
virtual void set (tree, tree, value_range_kind = VR_RANGE) override;
virtual bool contains_p (tree cst) const override;
irange (wide_int *, unsigned nranges, bool resizable);
+ irange (wide_int *, unsigned nranges, bool resizable, unsigned prec);
// In-place operators.
bool irange_contains_p (const irange &) const;
@@ -1177,6 +1178,18 @@ irange::irange (wide_int *base, unsigned nranges, bool
resizable)
set_undefined ();
}
+inline
+irange::irange (wide_int *base, unsigned nranges, bool resizable,
+ unsigned prec)
+ : vrange (VR_IRANGE),
+ m_resizable (resizable),
+ m_max_ranges (nranges),
+ m_bitmask (prec)
+{
+ m_base = base;
+ set_undefined ();
+}
+
// Constructors for int_range<>.
template<unsigned N, bool RESIZABLE>
@@ -1202,7 +1215,7 @@ int_range<N, RESIZABLE>::int_range (tree min, tree max,
value_range_kind kind)
template<unsigned N, bool RESIZABLE>
int_range<N, RESIZABLE>::int_range (tree type)
- : irange (m_ranges, N, RESIZABLE)
+ : irange (m_ranges, N, RESIZABLE, TYPE_PRECISION (type))
{
set_varying (type);
}