public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/31590] New: (-3) >> 1 should be -2.
@ 2024-04-02 5:57 tsqurt at outlook dot com
2024-04-02 12:38 ` [Bug c++/31590] " tromey at sourceware dot org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: tsqurt at outlook dot com @ 2024-04-02 5:57 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31590
Bug ID: 31590
Summary: (-3) >> 1 should be -2.
Product: gdb
Version: HEAD
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: tsqurt at outlook dot com
Target Milestone: ---
Affected versions (Ubuntu 20.04 amd64)
- GNU gdb (GDB) 14.2
- GNU gdb (GDB) 15.0.50.20240402-git
The result is correct (-2) for gdb 13.2 using 2's complement. But for gdb 14.2:
(gdb) p (-3) >> 1
$1 = -1
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/31590] (-3) >> 1 should be -2.
2024-04-02 5:57 [Bug gdb/31590] New: (-3) >> 1 should be -2 tsqurt at outlook dot com
@ 2024-04-02 12:38 ` tromey at sourceware dot org
2024-05-31 11:03 ` ssbssa at sourceware dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: tromey at sourceware dot org @ 2024-04-02 12:38 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31590
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|gdb |c++
CC| |tromey at sourceware dot org
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/31590] (-3) >> 1 should be -2.
2024-04-02 5:57 [Bug gdb/31590] New: (-3) >> 1 should be -2 tsqurt at outlook dot com
2024-04-02 12:38 ` [Bug c++/31590] " tromey at sourceware dot org
@ 2024-05-31 11:03 ` ssbssa at sourceware dot org
2024-05-31 11:51 ` ssbssa at sourceware dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: ssbssa at sourceware dot org @ 2024-05-31 11:03 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31590
Hannes Domani <ssbssa at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
CC| |ssbssa at sourceware dot org
Last reconfirmed| |2024-05-31
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/31590] (-3) >> 1 should be -2.
2024-04-02 5:57 [Bug gdb/31590] New: (-3) >> 1 should be -2 tsqurt at outlook dot com
2024-04-02 12:38 ` [Bug c++/31590] " tromey at sourceware dot org
2024-05-31 11:03 ` ssbssa at sourceware dot org
@ 2024-05-31 11:51 ` ssbssa at sourceware dot org
2024-06-11 18:37 ` cvs-commit at gcc dot gnu.org
2024-06-12 14:42 ` ssbssa at sourceware dot org
4 siblings, 0 replies; 6+ messages in thread
From: ssbssa at sourceware dot org @ 2024-05-31 11:51 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31590
--- Comment #1 from Hannes Domani <ssbssa at sourceware dot org> ---
https://sourceware.org/pipermail/gdb-patches/2024-May/209509.html
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/31590] (-3) >> 1 should be -2.
2024-04-02 5:57 [Bug gdb/31590] New: (-3) >> 1 should be -2 tsqurt at outlook dot com
` (2 preceding siblings ...)
2024-05-31 11:51 ` ssbssa at sourceware dot org
@ 2024-06-11 18:37 ` cvs-commit at gcc dot gnu.org
2024-06-12 14:42 ` ssbssa at sourceware dot org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-11 18:37 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31590
--- Comment #2 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Hannes Domani <ssbssa@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d17731525424349d7e63b517acf9f45114979fbb
commit d17731525424349d7e63b517acf9f45114979fbb
Author: Hannes Domani <ssbssa@yahoo.de>
Date: Tue Jun 11 20:32:27 2024 +0200
Fix right shift of negative numbers
PR31590 shows that right shift of negative numbers doesn't work
correctly since GDB 14:
(gdb) p (-3) >> 1
$1 = -1
GDB 13 and earlier returned the correct value -2.
And there actually is one test that shows the failure:
print -1 >> 1
$84 = 0
(gdb) FAIL: gdb.base/bitshift.exp: lang=asm: rsh neg lhs: print -1 >> 1
The problem was introduced with the change to gmp functions in
commit 303a881f87.
It's wrong because gdb_mpz::operator>> uses mpz_tdif_q_2exp, which
always rounds toward zero, and the gmp docu says this:
For positive n both mpz_fdiv_q_2exp and mpz_tdiv_q_2exp are simple
bitwise right shifts.
For negative n, mpz_fdiv_q_2exp is effectively an arithmetic right shift
treating n as two's complement the same as the bitwise logical functions
do, whereas mpz_tdiv_q_2exp effectively treats n as sign and magnitude.
So this changes mpz_tdiv_q_2exp to mpz_fdiv_q_2exp, since it
does right shifts for both positive and negative numbers.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31590
Approved-By: Tom Tromey <tom@tromey.com>
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/31590] (-3) >> 1 should be -2.
2024-04-02 5:57 [Bug gdb/31590] New: (-3) >> 1 should be -2 tsqurt at outlook dot com
` (3 preceding siblings ...)
2024-06-11 18:37 ` cvs-commit at gcc dot gnu.org
@ 2024-06-12 14:42 ` ssbssa at sourceware dot org
4 siblings, 0 replies; 6+ messages in thread
From: ssbssa at sourceware dot org @ 2024-06-12 14:42 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31590
Hannes Domani <ssbssa at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |16.1
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from Hannes Domani <ssbssa at sourceware dot org> ---
Fixed.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-06-12 14:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-02 5:57 [Bug gdb/31590] New: (-3) >> 1 should be -2 tsqurt at outlook dot com
2024-04-02 12:38 ` [Bug c++/31590] " tromey at sourceware dot org
2024-05-31 11:03 ` ssbssa at sourceware dot org
2024-05-31 11:51 ` ssbssa at sourceware dot org
2024-06-11 18:37 ` cvs-commit at gcc dot gnu.org
2024-06-12 14:42 ` ssbssa at sourceware dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).