This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug c++/16675] New: invalid value of sizeof or reference in gdb
- From: "vladi_ian at yahoo dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Fri, 07 Mar 2014 23:42:47 +0000
- Subject: [Bug c++/16675] New: invalid value of sizeof or reference in gdb
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=16675
Bug ID: 16675
Summary: invalid value of sizeof or reference in gdb
Product: gdb
Version: 7.7
Status: NEW
Severity: normal
Priority: P2
Component: c++
Assignee: unassigned at sourceware dot org
Reporter: vladi_ian at yahoo dot com
problem with printing size of reference in gdb. The output is the size of
pointer, not the size of type.
In the next program
#include <iostream>
int main()
{
typedef unsigned char a4[4];
a4 p1;
a4& p2 = p1;
std::cout<<sizeof(p2);
return 0;
}
Compile, start gdb and put breakpoint on return. If you type p sizeof(p2), gdb
will print 8 instead of 4 which will be printed if you start the program. If
you write in gdb p sizeof(*p2), the output is 4 (the size of array). I think
this is because gdb treats p2 as pointer(reference is implemented behind the
scene as pointer).
Tested with compilers GCC 4.8.2 and Clang 4.3 on GDB 7.7 linux arch., ubuntu
13.10,
There are also examples in
http://stackoverflow.com/questions/22255860/sizeof-reference-to-array-in-gdb?noredirect=1#comment33814516_22255860
--
You are receiving this mail because:
You are on the CC list for the bug.