diff options
author | Tom Tromey <tom@tromey.com> | 2023-11-24 12:10:53 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-12-08 08:17:40 -0700 |
commit | 44671f3f7f4c6435e7a639ad2215629f4e1ea8a7 (patch) | |
tree | b364744f0451f5e8704f94f454b1c943c8546e50 /gdb/gmp-utils.h | |
parent | 703adbb1f97db52ed63b2a6a074195b1cee0f132 (diff) | |
download | fsf-binutils-gdb-44671f3f7f4c6435e7a639ad2215629f4e1ea8a7.zip fsf-binutils-gdb-44671f3f7f4c6435e7a639ad2215629f4e1ea8a7.tar.gz fsf-binutils-gdb-44671f3f7f4c6435e7a639ad2215629f4e1ea8a7.tar.bz2 |
Allow cast of 128-bit integer to pointer
PR rust/31082 points out that casting a 128-bit integer to a pointer
will fail. This happens because a case in value_cast was not
converted to use GMP.
This patch fixes the problem. I am not really sure that testing
against the negative value here makes sense, but I opted to just
preserve the existing behavior rather than change it.
Regression tested on x86-64 Fedora 38.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31082
Diffstat (limited to 'gdb/gmp-utils.h')
-rw-r--r-- | gdb/gmp-utils.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gdb/gmp-utils.h b/gdb/gmp-utils.h index a5c27fe..52052e3 100644 --- a/gdb/gmp-utils.h +++ b/gdb/gmp-utils.h @@ -251,19 +251,32 @@ struct gdb_mpz return result; } + gdb_mpz operator- () const + { + gdb_mpz result; + mpz_neg (result.m_val, m_val); + return result; + } + gdb_mpz &operator<<= (unsigned long nbits) { mpz_mul_2exp (m_val, m_val, nbits); return *this; } - gdb_mpz operator<< (unsigned long nbits) const + gdb_mpz operator<< (unsigned long nbits) const & { gdb_mpz result; mpz_mul_2exp (result.m_val, m_val, nbits); return result; } + gdb_mpz operator<< (unsigned long nbits) && + { + mpz_mul_2exp (m_val, m_val, nbits); + return *this; + } + gdb_mpz operator>> (unsigned long nbits) const { gdb_mpz result; |