logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

c++/2378: print displays incorrect value when using a format on a variable : msg#00009

Subject: c++/2378: print displays incorrect value when using a format on a variable passed by reference
>Number:         2378
>Category:       c++
>Synopsis:       print displays incorrect value when using a format on a 
>variable passed by reference
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 07 04:18:01 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator:     Matt Blythe
>Release:        unknown-1.0
>Organization:
>Environment:
Linux/2.6.18 i686
GNU gdb 6.6.90.20070912-debian
This GDB was configured as "i486-linux-gnu".
>Description:
I have a function like "foo(unsigned int &temp)"

I want to display temp in hex or binary, so here's what I do:

(gdb) print temp
$36 = (unsigned int &) @0xb7fd117c: 4294966271
(gdb) print /x temp
$37 = 0xb7fd117c
(gdb) print /x *temp
Cannot access memory at address 0xfffffbff
(gdb) print /x &temp
$38 = 0xb7fd117c
(gdb) print /t temp
$39 = 10110111111111010001000101111100
(gdb) print /t *temp
Cannot access memory at address 0xfffffbff
(gdb) print /t &temp
$40 = 10110111111111010001000101111100

Whenever I try to "print /? temp" it displays the address of temp, not the 
value.  By that logic, I should be able to dereference temp in the statement to 
print the value.  Not so: it tries to dereference the value, not the address as 
expected.  I threw "print /? &temp" in just to see what it would do, and it 
printed the address, acting as if "temp" and "&temp" are the same thing.

If this isn't a "bug," then the behavior is at least inconsistent.  I expected 
the following:

(gdb) print temp
$36 = (unsigned int &) @0xb7fd117c: 4294966271
(gdb) print /x temp
$37 = 0xfffffbff
(gdb) print /x *temp
Cannot access memory at address 0xfffffbff
(gdb) print /x &temp
$38 = 0xb7fd117c
(gdb) print /t temp
$39 = 1111 1111 1111 1111 1000 1111 1111 (spaces added for my own benefit...not 
part of the bug, nor what I expect)
(gdb) print /t *temp
Cannot access memory at address 0xfffffbff
(gdb) print /t &temp
$40 = 10110111111111010001000101111100

I haven't tried this on a recent build, sorry.  I can in a few days (project 
deadlines are fast approaching)
>How-To-Repeat:
see Description
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



<Prev in Thread] Current Thread [Next in Thread>