klaiber@june.cs.washington.edu (Alexander Klaiber) (11/16/89)
I ran into a bug related to the "new" operation: ============================================================================= #include "stdio.h" class Foo { private: char* name; public: Foo(char* s); check(int, Foo* f, int); }; Foo::Foo(char* s) { name = s; } Foo::check(int a, Foo* f, int b) { printf("%d %d %d\n", a, (int)f, b); } main() { Foo a("test"); a.check(1, new Foo("crash"), 2); } ------------------------------------------------------------------------- [uw-larry - 120] % g++ main.c [uw-larry - 121] % a.out 1 148520 148520 ============================================================================= Apparently the stack gets clobbered by the "new" operation. If I change the main program as show below, things work fine ============================================================================= main() { Foo a("test"); Foo* b = new Foo("crash"); a.check(1, b, 2); } ------------------------------------------------------------------------- [uw-larry - 124] % g++ other.c [uw-larry - 125] % a.out 1 148520 2 ============================================================================= g++ version 1.36.1 (based on GCC 1.36) Sun3, os3 Any help would be **GREATLY** appreciated... Alex