[Bug gdb/34416] Incorrect loss of sign in 64-bit multiply (e.g.: DW_OP_mul in DWARF evaluation)

tromey at sourceware dot org via Gdb-prs <[email protected]>
Newsgroups gmane.comp.gdb.bugs.discuss
Message-ID <[email protected]/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=34416

--- Comment #4 from Tom Tromey <tromey at sourceware dot org> ---
Seems to be from

commit 303a881f8789733248f27af0c872d356a34be009
Author: Tom Tromey <[email protected]>
Date:   Wed Mar 1 15:13:21 2023 -0700

    Use gdb_gmp for scalar arithmetic

In particular this runs afoul of this code in gdb_mpz::read

  if (!unsigned_p)
    {
      /* The value was imported as if it was a positive value,
         as mpz_import does not handle signs. If the original value
         was in fact negative, we need to adjust VAL accordingly.  */
      gdb_mpz max;

      mpz_ui_pow_ui (max.m_val, 2, buf.size () * HOST_CHAR_BIT - 1);
      if (mpz_cmp (m_val, max.m_val) >= 0)
        mpz_submul_ui (m_val, max.m_val, 2);
    }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.