www.digitalmars.com         C & C++   DMDScript  

c++.beta - Object array crash

reply Riccardo Macri <Riccardo_member pathlink.com> writes:
This crashes (between "2" and "3") unless the destructor is enabled.
The code it was derived from worked under SC7.5.

Apologies if I've misunderstood the use of object arrays!

regards,
Rick

---

#include <stdio.h>

//
// Compile: sc test2
//
// This program crashes. If USE_DESTRUCTOR is enabled, its OK
//

//#define USE_DESTRUCTOR 1

class Test2
{
int foo;

public:

Test2();

#ifdef USE_DESTRUCTOR
~Test2()   {}
#endif
};

Test2::Test2()
{
foo = 123;
};

main()
{
printf("1\n");
Test2 * ptr = new Test2[500];
printf("2\n");
delete [] ptr;
printf("3\n");

return 0;
};
Mar 03 2004
parent reply Riccardo Macri <Riccardo_member pathlink.com> writes:
Any comments on why my previous posting (3rd of March) crashes?

Its repeated below.

thanks
Riccardo

In article <c24rsr$12fo$1 digitaldaemon.com>, Riccardo Macri says...
This crashes (between "2" and "3") unless the destructor is enabled.
The code it was derived from worked under SC7.5.

Apologies if I've misunderstood the use of object arrays!

regards,
Rick

---

#include <stdio.h>

//
// Compile: sc test2
//
// This program crashes. If USE_DESTRUCTOR is enabled, its OK
//

//#define USE_DESTRUCTOR 1

class Test2
{
int foo;

public:

Test2();

#ifdef USE_DESTRUCTOR
~Test2()   {}
#endif
};

Test2::Test2()
{
foo = 123;
};

main()
{
printf("1\n");
Test2 * ptr = new Test2[500];
printf("2\n");
delete [] ptr;
printf("3\n");

return 0;
};
Apr 07 2004
parent "Walter" <walter digitalmars.com> writes:
No, not yet, sorry.

"Riccardo Macri" <Riccardo_member pathlink.com> wrote in message
news:c51m64$10hr$1 digitaldaemon.com...
 Any comments on why my previous posting (3rd of March) crashes?

 Its repeated below.

 thanks
 Riccardo
Apr 07 2004