public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug exp/18617] New: Incorrect expression bytecode generated for narrowing conversions
@ 2015-07-01  5:55 robert at ocallahan dot org
  2015-07-01 18:38 ` [Bug exp/18617] " khuey at kylehuey dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: robert at ocallahan dot org @ 2015-07-01  5:55 UTC (permalink / raw)
  To: gdb-prs

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.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-07-08 10:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-01  5:55 [Bug exp/18617] New: Incorrect expression bytecode generated for narrowing conversions robert at ocallahan dot org
2015-07-01 18:38 ` [Bug exp/18617] " khuey at kylehuey dot com
2015-07-01 21:56 ` robert at ocallahan dot org
2015-07-02 14:27 ` palves at redhat dot com
2015-07-03  1:17 ` robert at ocallahan dot org
2015-07-08 10:10 ` cvs-commit at gcc dot gnu.org
2015-07-08 10:17 ` cvs-commit at gcc dot gnu.org
2015-07-08 10:20 ` palves at redhat dot com

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).