http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53225

--- Comment #11 from Thomas W. Lynch <dimitrisdad at gmail dot com> 2012-05-04 
19:59:12 UTC ---
Jonathan, but there is "magical adjustment" as you put it, as the following
code works correctly:

#include <cstddef>
#include <stdlib.h>
typedef unsigned int uint;

class C{ // just here to be faithful to the original code
  int y;
};


class A{
public:
  typedef A this_type;

  void* method(uint count){
    void *vp;
    vp = (void *)this;
    this_type *p;
    p = (this_type *)vp;
    p->count = count;   
  };

  uint count;
};

class B : public C, public A{
public:
    typedef B this_type;
    int i;
};

int main(){
  int j;

  A a;
  a.method(5);
  j++;

  B b;
  b.method(5);
  j++;

};


note the output in gdb where the '5' jumps to a new offset:

(gdb) b main
Breakpoint 1 at 0x80484a1: file try_offsets_2.ex.cc, line 36.
(gdb) r
Starting program: /try_offsets_2 
Breakpoint 1, main () at try_offsets_2.ex.cc:36
(gdb) n
(gdb) 
$1 = (A *) 0xbffff758
(gdb) x /10x &a
0xbffff758:    0x00000005    0x003dbff4    0x08048500    0x003dbff4
0xbffff768:    0x00000000    0x0027d113    0x00000001    0xbffff804
0xbffff778:    0xbffff80c    0x0012eff4
(gdb) n
(gdb) x /10x &b
0xbffff74c:    0x003dc324    0x00000005    0x00296c55    0x00000005
0xbffff75c:    0x003dbff5    0x08048500    0x003dbff4    0x00000000
0xbffff76c:    0x0027d113    0x00000001
(gdb)

Reply via email to