c++/1210: Printing fails/aborts for some attributes (Cannot access memory at address)

Michael Bjerking michaelbjerking@hotmail.com
Sat Mar 18 08:58:00 GMT 2006

The following reply was made to PR c++/1210; it has been noted by GNATS.

From: Michael Bjerking <michaelbjerking@hotmail.com>
To: gdb-gnats@sources.redhat.com
Subject: Re: c++/1210: Printing fails/aborts for some attributes (Cannot
	access memory at address)
Date: Sat, 18 Mar 2006 09:50:03 +0100

 This bug still exist in gdb v6.3.50 and !?
 Here is output from the testsuite:
 mbj@linux:~/gdb-> runtest
 WARNING: No tool specified
 Test Run By mbj on Sat Mar 18 09:33:31 2006
 Native configuration is i686-suse-linux
                 ===  tests ===
 Schedule of variations:
 Running target unix
 Using /usr/share/dejagnu/baseboards/unix.exp as board description file
 for target.
 Using /usr/share/dejagnu/config/unix.exp as generic interface file for
 Using ./../config/unix.exp as tool-and-target-specific interface file.
 Running ./pr-1210.exp ...
 FAIL: print *obj
 FAIL: print obj->myB
                 ===  Summary ===
 # of expected passes            1
 # of unexpected failures        2
 I have also a very simple example where the problem is accuring:
 > cat main.cpp
 #include <iostream>
 using namespace std;
 class Info {
     int i_;
     int geti();
 class Base {
     int a_;
     double b_;
     Info id_;
     Base() { id_.i_ = 10; }
     int geta() { return a_; }
     double getb() { return b_; }
     Info id() { return id_; }
 Info::geti() {
     return i_;
 int main()
     Base base;
     cout << "Start" << endl;
     cout << base.id().geti() << endl;
     cout << "End" << endl;
     return 0;
 > cat Makefile
 GCC = g++
 CCFLAGS = -g -ggdb
 all: main
 main: main.o
         $(GCC) $(CCFLAGS) main.o -o main
 main.o: main.cpp
         $(GCC) $(CCFLAGS) -o main.o -c main.cpp
         rm main.o
         rm main
 mbj@linux:~/moduletesting> gdb main
 GNU gdb
 Copyright (C) 2006 Free Software Foundation, Inc.
 GDB is free software, covered by the GNU General Public License, and you
 welcome to change it and/or distribute copies of it under certain
 Type "show copying" to see the conditions.
 There is absolutely no warranty for GDB.  Type "show warranty" for
 This GDB was configured as "--host= --target=i686-pc-linux-gnu"...Using
 host libthread_db library "/lib/tls/libthread_db.so.1".
 (gdb) b main
 Breakpoint 1 at 0x80486ee: file main.cpp, line 30.
 (gdb) r
 Starting program: /home/mbj/moduletesting/main
 Breakpoint 1, main () at main.cpp:30
 30          Base base;
 (gdb) n
 32          cout << "Start" << endl;
 (gdb) n
 33          cout << base.id().geti() << endl;
 (gdb) n
 34          cout << "End" << endl;
 (gdb) p base.id().geti()
 Attempt to take address of value not located in memory.

More information about the Gdb-prs mailing list