Path: chuka.playstation.co.uk!chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: "Wayne K. Werner" Newsgroups: scea.yaroze.problems.pc,scea.yaroze.programming.codewarrior Subject: Re: Yet Another CodeWarrior Problem Date: 20 Sep 1997 07:35:20 GMT Organization: WermX Software Lines: 45 Message-ID: <01bcc597$80ca33c0$81bf43ce@wkwerner> References: <34236F6C.16A9@ix.netcom.com> NNTP-Posting-Host: port29.con2.com X-Newsreader: Microsoft Internet News 4.70.1161 Xref: chuka.playstation.co.uk scea.yaroze.problems.pc:142 scea.yaroze.programming.codewarrior:198 Spellweaver wrote: > Look at the beginning of main(), where there > are two OBJECT declarations. Comment out the active > declaration and un-comment the other declaration. Save, > rebuild, and run. Lo and behold, the image is gone! > > int main ( void ) > { > OBJECT obj; > MATRIX mat; > //OBJECT obj; > GsF_LIGHT light; I didn't get a chance to check out your code to see what you're doing, but it is my experience that when the order of definition of automatic variables changes the behavior of a program, it is usually due to a memory overwrite. Since stacks grow down, the last item defined is probably at the lowest address, and the variable above is probably being overwriten via the variable below. Changing the order places either obj or mat before light. It is possible that light, obj or mat is the overflowed culprit (it wasn't clear to me which order of mat and obj worked correctly for you.) Of course, runaway pointers could also be the cause of a memory overwrite. I doubt that the CW compiler is failing at something as basic as setting up automatic variables on the stack. If this were the case, CW would be hard pressed to make even the most basic hello world program work. I have compiled some complicated GNU demos under CW. All have worked, as far as I can tell. (Well, at least as well as their GNU compiles.) Have you tried using the GNU compiler on this to see if it really is a compiler error and not a program error? If program error, it might not fail in the same way, but I would still expect a failure. It's a shame we don't have anything as sophisticated as a bound checker. I wonder... do the professional developers have that? Good luck and happy bug hunting! -- Wayne K. Werner wkwerner@con2.com