Fix bug in frange::contains_p() for signed zeros.
The contains_p() code wasn't returning true for non-singleton ranges containing signed zeros. With this patch we now handle: -0.0 exists in [-3, +5.0] +0.0 exists in [-3, +5.0] gcc/ChangeLog: * value-range.cc (frange::contains_p): Fix signed zero handling. (range_tests_signed_zeros): New test.
This commit is contained in:
parent
6d9dbdf51f
commit
58511b3fc0
1 changed files with 9 additions and 1 deletions
|
@ -661,7 +661,7 @@ frange::contains_p (tree cst) const
|
|||
{
|
||||
// Make sure the signs are equal for signed zeros.
|
||||
if (HONOR_SIGNED_ZEROS (m_type) && real_iszero (rv))
|
||||
return m_min.sign == m_max.sign && m_min.sign == rv->sign;
|
||||
return rv->sign == m_min.sign || rv->sign == m_max.sign;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -3859,6 +3859,14 @@ range_tests_signed_zeros ()
|
|||
ASSERT_TRUE (r0.contains_p (neg_zero));
|
||||
ASSERT_FALSE (r0.contains_p (zero));
|
||||
|
||||
r0 = frange (neg_zero, zero);
|
||||
ASSERT_TRUE (r0.contains_p (neg_zero));
|
||||
ASSERT_TRUE (r0.contains_p (zero));
|
||||
|
||||
r0 = frange_float ("-3", "5");
|
||||
ASSERT_TRUE (r0.contains_p (neg_zero));
|
||||
ASSERT_TRUE (r0.contains_p (zero));
|
||||
|
||||
// The intersection of zeros that differ in sign is a NAN (or
|
||||
// undefined if not honoring NANs).
|
||||
r0 = frange (neg_zero, neg_zero);
|
||||
|
|
Loading…
Add table
Reference in a new issue