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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

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

From: Michael Bjerking <[hidden email]>
To: [hidden email]
Cc:  
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 6.4.50.20060316 !?
 
 Here is output from the testsuite:
 
 mbj@linux:~/gdb-6.4.50.20060316/gdb/testsuite/gdb.cp> runtest
 pr-1210.exp
 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:
     unix
 
 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
 target.
 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 {
 public:
     int i_;
     int geti();
 };
 
 class Base {
     int a_;
     double b_;
     Info id_;
 
 public:
     Base() { id_.i_ = 10; }
     int geta() { return a_; }
     double getb() { return b_; }
     Info id() { return id_; }
 };
 
 int
 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
 
 clean:
         rm main.o
         rm main
 ===================================================
 
 mbj@linux:~/moduletesting> gdb main
 GNU gdb 6.4.50.20060316
 Copyright (C) 2006 Free Software Foundation, Inc.
 GDB is free software, covered by the GNU General Public License, and you
 are
 welcome to change it and/or distribute copies of it under certain
 conditions.
 Type "show copying" to see the conditions.
 There is absolutely no warranty for GDB.  Type "show warranty" for
 details.
 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
 Start
 33          cout << base.id().geti() << endl;
 (gdb) n
 10
 34          cout << "End" << endl;
 (gdb) p base.id().geti()
 Attempt to take address of value not located in memory.
 (gdb)