This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
help please with simple one!
- From: "Raghu Vadapalli" <raghuv119 at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 10 Aug 2007 17:07:42 -0400
- Subject: help please with simple one!
I have a simple program which works when I compile with my g++
from command line like: g++ test.cpp --- no problems.
but If I do g++ -m32 test.cpp it crashes right at the delete [] temp
statement. If I change the temp pointer type to Child all is well.
what am I doing wrong. If you guys just say I am just dumb that's
good.but I need to know what's wrong. my g++ version is listed beflow
for your reference. please CC to my email address as I am not on any
kind of mailing list related gnu gcc. Thanks for all your help.
see the code below.
#include <iostream>
static int mcount = 0;
using namespace std;
class Base
{
public:
Base( int i, int j) { };
virtual ~Base() {cout <<"delete"<<endl; };
virtual void hui() { cout <<"hello world"<<endl; };
private:
int temp12;
};
class Child : public Base
{
public:
Child(int i, int j) : Base(i,j) {};
virtual ~Child() {};
virtual void hui() { cout <<"world hello world"<<endl; };
private:
int temp23;
};
int main(int argc, char **argv)
{
Base *temp = new Child [1024] (3, 2);
temp[0].hui();
delete [] temp;
}
--
Regards
Raghu