From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C6820384EF73; Tue, 6 Dec 2022 12:33:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C6820384EF73 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670330016; bh=A2X102Ht0bJaSKulu8TjPJgRd+fXv3dvYn4jUjQ7DUA=; h=From:To:Subject:Date:From; b=GLUHiEax8ihM8hOIXWYpao8FZwNdjuFjEjL2n2JOP+MZvIFZFfz/5XQBJaUO6Edra xr7ZjZFUvMiRGW13k/bvdBjYXVXQ527sPv3EXGprnWYdcyYa0cGTad8YNxrX76DcHG xkU91z0+AknpQxj+hkpW93a6nPkldoCWtZf20Qb4= From: "bpeeluk at yahoo dot co.uk" To: gdb-prs@sourceware.org Subject: [Bug rust/29859] New: Printing rust expressions with simple arithmetic gets wrong result Date: Tue, 06 Dec 2022 12:33:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: rust X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bpeeluk at yahoo dot co.uk X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29859 Bug ID: 29859 Summary: Printing rust expressions with simple arithmetic gets wrong result Product: gdb Version: HEAD Status: UNCONFIRMED Severity: normal Priority: P2 Component: rust Assignee: unassigned at sourceware dot org Reporter: bpeeluk at yahoo dot co.uk Target Milestone: --- The rust parser doesn=E2=80=99t seem to handle expressions with multiple bi= nary operators but no parentheses correctly: (gdb) p 3 - 2 - 1 $1 =3D 2 (gdb) p 5 * 4 / 3 $2 =3D 5 It seems to be calculating the answer as if the operators were right-to-lef= t: (gdb) p 3 - (2 - 1) $3 =3D 2 (gdb) p 5 * (4 / 3) $4 =3D 5 But it should be doing left-to-right: (gdb) p (3 - 2) - 1 $5 =3D 0 (gdb) p (5 * 4) / 3 $6 =3D 6 I tested this with the current git master which is c8ea5e409b02cf7fa8. Another way to test this could be to add the following lines to the bottom = of gdb/testsuite/gdb.rust/expr.exp: gdb_test "print 3 - 2 - 1" " =3D 0" gdb_test "print 5 * 4 / 3" " =3D 6" and then run: ( cd gdb/testsuite && runtest gdb.rust/expr.exp ) --=20 You are receiving this mail because: You are on the CC list for the bug.=