Article View: gnu.g++.bug
Article #590g++ 1.36.1 bug
From: Alexander Klaiber
Date: Thu, 16 Nov 1989 10:51
Date: Thu, 16 Nov 1989 10:51
64 lines
1891 bytes
1891 bytes
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
Technical Details
Message-ID:
<9823@june.cs.washington.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mit-eddie!uw-beaver!uw-june!june.cs.washington.edu!klaiberShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mit-eddie!uw-beaver!uw-june!june.cs.washington.edu!klaiber From: klaiber@june.cs.washington.edu (Alexander Klaiber) Newsgroups: gnu.g++.bug Subject: g++ 1.36.1 bug Keywords: new, ___builtin_new, clobber stack Message-ID: <9823@june.cs.washington.edu> Date: 16 Nov 89 10:51:03 GMT Sender: klaiber@cs.washington.edu Reply-To: klaiber@june.cs.washington.edu (Alexander Klaiber) Organization: U of Washington, Computer Science, Seattle Lines: 64