https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78555
Bug ID: 78555
Summary: gcc/sreal.c:232:20: runtime error: left shift of
negative value -2018967552
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ipa
Assignee: unassigned at gcc dot gnu.org
Reporter: trippels at gcc dot gnu.org
Target Milestone: ---
bootstrap-ubsan on ppc64le hits the following error very often:
gcc/sreal.c:232:20: runtime error: left shift of negative value -2018967552
I will test:
diff --git a/gcc/sreal.c b/gcc/sreal.c
index 9c43b4e..ceb63b7 100644
--- a/gcc/sreal.c
+++ b/gcc/sreal.c
@@ -227,9 +227,10 @@ sreal::operator* (const sreal &other) const
sreal
sreal::operator/ (const sreal &other) const
{
+ int64_t sign = m_sig < 0 ? -1 : 1;
gcc_checking_assert (other.m_sig != 0);
sreal r;
- r.m_sig = (m_sig << SREAL_PART_BITS) / other.m_sig;
+ r.m_sig = sign * (absu_hwi (m_sig) << SREAL_PART_BITS) / other.m_sig;
r.m_exp = m_exp - other.m_exp - SREAL_PART_BITS;
r.normalize ();
return r;