From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 54607 invoked by alias); 1 Jul 2015 05:55:43 -0000 Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org Received: (qmail 54584 invoked by uid 48); 1 Jul 2015 05:55:42 -0000 From: "robert at ocallahan dot org" To: gdb-prs@sourceware.org Subject: [Bug exp/18617] New: Incorrect expression bytecode generated for narrowing conversions Date: Wed, 01 Jul 2015 05:55:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: exp X-Bugzilla-Version: 7.9 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: robert at ocallahan dot org X-Bugzilla-Status: NEW 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: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-q3/txt/msg00001.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=18617 Bug ID: 18617 Summary: Incorrect expression bytecode generated for narrowing conversions Product: gdb Version: 7.9 Status: NEW Severity: normal Priority: P2 Component: exp Assignee: unassigned at sourceware dot org Reporter: robert at ocallahan dot org Target Milestone: --- Given the program: uint64_t u64max = (uint64_t)(int64_t)-1; int main(int argc, char* argv[]) { return 0; } and the commands break main cond 1 (unsigned char)u64max==255 the following expression bytecode is generated: {0x24, 0x0, 0x60, 0xd, 0x38, 0x1a, 0x2a, 0x40, 0x23, 0x0, 0xff, 0x13, 0x27} That is: const32 0x600d38 ref64 zero_ext 64 const16 0xff equal end The zero_ext operand is incorrect. It should have been 8, to keep the low 8 bits and zero the rest. The breakpoint condition therefore returns false when it should return true. The bug is in ax-gdb.c: /* If we're converting to a narrower type, then we need to clear out the upper bits. */ if (TYPE_LENGTH (to) < TYPE_LENGTH (from)) gen_extend (ax, from); That should be gen_extend (ax, to); to keep `to` bits and zero the rest. -- You are receiving this mail because: You are on the CC list for the bug.