www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/17/15:10:22

From: NG Chi Fai <cfng1 AT netvigator DOT com>
Newsgroups: comp.os.msdos.djgpp,comp.lang.c++
Subject: Problems using CYGWIN
Date: Sun, 16 May 1999 23:47:56 -0700
Organization: oronet, Penn Valley, C
Lines: 55
Message-ID: <373FBB9C.FE26B278@netvigator.com>
NNTP-Posting-Host: gv1-241.oro.net
Mime-Version: 1.0
X-Server-Date: 17 May 1999 06:48:39 GMT
X-Mailer: Mozilla 4.51 [en] (Win95; I)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hello,

I used DJGPP and CYGWIN to compile the following code. DJGPP runs as
expected while CYGWIN reports

Program received signal SIGSEGV, Segmentation fault.
0x6105b0f3 in _size_of_stack_reserve__ ()

Please help solve the problem. It seems the Segmentation fault happens
after the cout << line. However, there is something wrong before the
cout << line because the output data are corrupted.

// code follows, I've removed some lines that I think is irrelevant.
#include <iostream.h>

template < class T >
class a
{
	private:
	public:
		T* t;
		a(void) {t=new T[256];};
		~a(void) {delete[] t;};
		template < class U > a<T> & operator = (const a<U> &v) 
		{
			int i;
			for(i=0;i<256;i++)
			{
				t[i]=T(v.t[i]);
			}
			return *this;
		};
		void fill ( const T & h) { ... };
		a<T> duplicate(void)
		{
			a<T> temp;
			temp=*this;
			return temp;
		};
		friend ostream & operator << <T> (ostream& out, const a<T>& t);
};

int main(void)
{
	a<int> b;
	a<float> c;
	a<float> d;
	b.fill (99);
	c.fill (88.888);
	d=b;
	b=c;
	c.duplicate();
	cout << b << c << d;
	return 0;
}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019