Subject: Bizarre g++ behavior on sparc
To: None <current-users@NetBSD.ORG>
From: Aaron Brown <abrown@eecs.harvard.edu>
List: current-users
Date: 05/01/1996 19:48:19
Has anyone had trouble with g++ on the sparc port (specifically the Sun4m)
or any other port recently? This simple program:

#include <iostream.h>
#include <fstream.h>

int main(void)
{
	char c = 'x';
	ifstream in("test");

	if (in)
		in.get(c);

	cout << "Read char " << c << endl;
	return 0;
}

segfaults when run. (test is non-empty). I built libg++ and libstdc++ with
debugging symbols, and as far as I can tell, the "this" pointer is getting
trashed somewhere inside istream::get(). It starts out as a nice stack
address (0xf7fff548 or something) and then turns into 0x4000xxxx by the
time it gets to ipfx1 inside istream::get(). 

This program runs on NetBSD-1.1/i386 just fine. Has anyone seen similar
strange behavior and/or can anyone else reproduce this? (I'm trying to
find out if it is in some bizarre way a sun4m port bug). This is with the
most current libg++/g++/gcc/libc/etc (all built yesterday).

Of course, if I'm being clueless (it's been a while since I did real work
in C++), please feel free to flame me :-)

--Aaron