This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.
See the CrossGCC FAQ for lots more information.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Hi folks,
I wonder if anybody has any thoughts on a little problem I have.
Apologies in advance for the length of this post.
I have a struct:
struct Wibble { int blah[1]; };
and a pair of classes which have members which return a Wibble type:
class A
{
public:
virtual Wibble F();
};
class B
{
public:
virtual Wibble F();
};
and a derived class which also returns a Wibble type:
class C : public A, public B
{
public:
Wibble F();
};
In the class definitions, I simply write the this pointer to an output
port and return a copy of a wibble instance:
Wibble wibble;
Wibble A::F()
{
cdbg() << "A:" << (int) this << "\n";
return (wibble);
}
Wibble B::F()
{
cdbg() << "B:" << (int) this << "\n";
return (wibble);
}
Wibble C::F()
{
cdbg() << "C:" << (int) this << "\n";
return (wibble);
}
And finally, my entry function on an embedded system is:
int C_Entry(void)
{
C c_obj;
C* c = &c_obj;
cdbg() << SerPortStream::hex;
A * a = c;
B * b = c;
cdbg() << "A:" << (int) a << "\n";
cdbg() << "B:" << (int) b << "\n";
cdbg() << "C:" << (int) c << "\n";
a->F();
b->F();
c->F();
cdbg() << "Complete\n";
return (0);
}
The observed ouput is:
A:3fddc
B:3fde0
C:3fddc
C:3fddc
C:3fde0
C:3fde0
Complete
Which I find disturbing because clearly c's pointer value is
inconsistent.
Furthermore, if I change my struct definition to remove the array:
struct Wibble { int blah; };
then I get output as expected:
A:3fddc
B:3fde0
C:3fddc
C:3fddc
C:3fddc
C:3fddc
Complete
Anybody had any similar problems ? Are there any work arounds or patches
?
--
Andy Parker Oxford Semiconductor Ltd
Tel: +44 (0) 1235 824 944 25 Milton Park, Abingdon,
Fax: +44 (0) 1235 821 141 Oxfordshire. OX14 4SH
andy.parker@oxsemi.com http://www.oxsemi.com
------
Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |