🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Alexander Klaiber Thu, 16 Nov 1989 10:51
g++ 1.36.1 bug
#590
Author: Alexander Klaiber
Date: Thu, 16 Nov 1989 10:51
64 lines
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads