Path: chuka.playstation.co.uk!news From: sceetech Newsgroups: scee.yaroze.programming.3d_graphics,scee.yaroze.programming.gnu_compiler,scee.yaroze.programming.codewarrior Subject: Re: Best Compiler bug ever (almost) Date: Thu, 10 Apr 1997 10:47:35 +0100 Organization: SCEE Lines: 53 Message-ID: <334CB737.3E25@interactive.sony.com> References: <334c572f.9721328@news.playstation.co.uk> Reply-To: ps_yaroze@interactive.sony.com NNTP-Posting-Host: 194.203.13.10 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.01 (Win95; I) Xref: chuka.playstation.co.uk scee.yaroze.programming.3d_graphics:68 scee.yaroze.programming.gnu_compiler:15 scee.yaroze.programming.codewarrior:30 Alex Amsel wrote: > > We have come up against several compiler and ps-x bugs so far, > including gcc crashing on -O3 compiles [stack error] on simple code > and some other stuff, but this is brilliant! > > The following code kills the Yaroze. Something to do with the variable > name length (9) although longer and shorter seems ok. Only occurs with > certain sized arrays (something to do with odd values?) and with > unsigned shorts possibly. Anyway, mad mad mad bug. libps.h doesn't > need to be included. > > unsigned short PlayerMap[3*5]; > > main() > { > } > > * Alex Amsel * Into Beyond Web Design & JAVA Programming * > * http://www.intobeyond.com * WWFC Play off ****ers'97 * > MM: "Hand the opposition the lead, the supporters love it" Firstly: the crashing on optimisation with stack error is simply the fact that GNU wants massive of stack space when optimising. use << set go32=dpmistack 2000000 >> eg in djsetup.bat to ensure it never runs out of stack space. Secondly: trying your code fragment here, we notice that the length of the name of the array makes NO difference at all, the fragment always crashes the Yaroze. We suspect that it is simply the declaration of an array with an odd number of elements, together with element size being small, hence there is no aligning on 32bit boundary; the machine is purely 32bit, and manuals specifically say that non-32bit access will cause errors. The REMEDY for this problem is not hard to find: always declare arrays (and structures, etc, see libps.h) so that they always align on 4-byte boundaries. However, I have programmed on Yaroze for months without ever considering the need to do this, never padding structures to 4 bytes etc, and have NEVER had this problem. I must ask exactly what kind of activity led you to discover this 'problem'; were you testing the reliability of the compiler / Yaroze? Hope to hear from you soon Lewis