This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
gdb/635: bad memory access on uninitialized static const members w. -gdwarf-2
- From: carlton at math dot stanford dot edu
- To: gdb-gnats at sources dot redhat dot com
- Date: 6 Aug 2002 18:37:34 -0000
- Subject: gdb/635: bad memory access on uninitialized static const members w. -gdwarf-2
- Reply-to: carlton at math dot stanford dot edu
>Number: 635
>Category: gdb
>Synopsis: bad memory access on uninitialized static const members w. -gdwarf-2
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Aug 06 11:38:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: carlton@math.stanford.edu
>Release: unknown-1.0
>Organization:
>Environment:
uname -a:
Linux jackfruit.Stanford.EDU 2.4.18-5 #1 Mon Jun 10 15:31:48 EDT 2002 i686 unknown
gcc -v:
Configured with: ../gcc-3.1/configure --enable-languages=c++
Thread model: single
gcc version 3.1
GDB:
GNU gdb 2002-07-25-cvs
This GDB was configured as "i686-pc-linux-gnu"...
>Description:
When compiling C++ code generated by g++ -gdwarf-2, you get the message "Cannot access memory at address 0x0" when trying to print out uninitialized static const members of classes.
Exactly why one would create classes with uninitialized static const members is a good question; the code that I derived my example from was generated by a program, for what that's worth. But it does seem to be legal C++.
This example was derived from PR gdb/574: the code given there triggers several bugs in GDB other than the one that the original submitter mentioned, so I'm submitting them separately.
>How-To-Repeat:
Compile the following code:
class C {
public:
static const int bar; // Uninitialized static const.
};
int main()
{
C theC;
}
with g++ -gdwarf-2. (Either g++ 3.1 or 2.9something, I think.)
Then:
$ gdb a.out
(gdb) b main
Breakpoint 1 at 0x80484a0: file test-4.cc, line 9.
(gdb) r
Starting program: /home/carlton/gdb/bugs/574/test-4/a.out
Breakpoint 1, main () at test-4.cc:9
9 }
(gdb) p theC
$1 = {static bar = Cannot access memory at address 0x0
>Fix:
A patch will be forthcoming shortly.
>Release-Note:
>Audit-Trail:
>Unformatted: