Date: Wed, 22 Jan 1997 07:25:59 -0500 (EST) From: "Mike A. Harris" Reply-To: "Mike A. Harris" To: Adam Kunen cc: djgpp AT delorie DOT com Subject: Re: Bug report: Structs In-Reply-To: <199701220247.UAA37718@audumla.students.wisc.edu> Message-ID: Organization: Your mom. MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 21 Jan 1997, Adam Kunen wrote: > I think this is the right address for bug reports on DOS port of GNU > C... But anyway, I was using GNU C and found that when you have a structure > bigger than 64k it tends to crash. Although I havn't spent time to pinpoint > exactly what is causing the problem, I beleive that it crashes when you make > a function call with a large structure as an argument. I assume that doing > this is okay because gcc doesn't report any warnings or errors, so I've come > to the conclusion: It's a bug! > I hope this helps, > Adam Kunen, > kkunen AT facstaff DOT wisc DOT edu > > > > > PS: I was told to give an example code file to illustrate the problem: > > struct FooType { > char blah[1024][128]; > }; > > void foobar(struct FooType ptr){ > return; > } > > int main(void){ > struct FooType eek; > foobar(eek); > return 0; > } You are passing a 128k struct to the function foobar(). This is placed on the stack!!!!! You should never pass a struct to a function. Pass the address instead. ie: void foobar(struct FooType *ptr) {return;} Then in main put: foobar(&eek); Good luck. Mike A. Harris - Computer Consultant http://www3.sympatico.ca/mharris My dynamic address: http://www3.sympatico.ca/mharris/ip-address.html mailto:mharris AT sympatico DOT ca mailto:mharris AT blackwidow DOT saultc DOT on DOT ca LINUX: Lost your video after running a game or DOSemu, email me for fix.