BTW, here is the compiler line I'm using:

gcc -mcpu=strongarm110 -mapcs-32 -O2 -fno-builtin -fno-exceptions
-fvolatile -Wall -g nr.cc

It turns out that removing -fvolatile makes the problem go away, and the
this pointers match up.  Anyone have any idea why?  Thanks!

--
Kyle Mestery                    | StorageTek's Storage Networking Group
[EMAIL PROTECTED]                | http://www.freebsd.org/
[EMAIL PROTECTED]           | http://www.netwinder.org/
        Protect your right to privacy: www.freecrypto.org

---------- Forwarded message ----------
Date: Tue, 29 Jun 1999 12:51:40 -0500 (CDT)
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: Nathan Ahlstrom <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
Subject: Possible compiler bug?


I think I might have found a compiler bug, but I'm not sure yet.  The
program that causes the bug is attached.  The attached c++ program
basically defines two classes, A and B.  A contains an array of class B
in it.  The destructor and constructor for A do nothing, and the
destructor and constructor for B simply print out the 'this' pointer.
The main loop of the program simply news an instance of A, and then
deletes that instance.

What I'm seeing is that the this pointers in the constructors do not match
the this pointers in the destructors.  I have tried this on three
platforms:

1) Linux/ARM running 2.2.10-rmk2-stk2, with compiler version (gcc version
egcs-2.91.66 199903 25/philb (egcs-1.1.2 release)).
2) vxWorks 5.4, with compiler versions gcc version 2.8.1 and Egcs
version (gcc driver version 2.7.9-970819 egcs-971225 tornado 2.0
executing gcc version 2.7.9-970819).
3) Solaris 2.5.1 with compiler version gcc version 2.7.2.2.

The code fails on both of the ARM platforms, and works correctly under
Solaris (i.e. the 'this' pointers all match up.)  It looks like it might
be a ARM specific problem.  Does anyone have any ideas about this?

--
Kyle Mestery                    | StorageTek's Storage Networking Group
[EMAIL PROTECTED]                | http://www.freebsd.org/
[EMAIL PROTECTED]           | http://www.netwinder.org/
        Protect your right to privacy: www.freecrypto.org
#include <stdio.h>
#define NUM 5

class OtherClass
{
public:
        OtherClass();
        ~OtherClass();
};

class MyTest {

public:
        MyTest();
        ~MyTest();

        OtherClass OC[NUM]; //[NUM];
};


MyTest::MyTest() {
}
MyTest::~MyTest() {
}


OtherClass::OtherClass()
{
        printf("oc = 0x%08x\n", (int)this);
}

OtherClass::~OtherClass()
{
        printf("oc = 0x%08x\n", (int)this);
}

int main()
{
        MyTest *ntest;
        ntest = new MyTest;
        printf("new MyTest = 0x%08x\n", (int)ntest);
        delete ntest;
        return 0;
}

Reply via email to