From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb9cd,10b7a9a3731f3fc8 X-Google-Attributes: gidfb9cd,public X-Google-Thread: f782f,10b7a9a3731f3fc8 X-Google-Attributes: gidf782f,public X-Google-Thread: 1125fa,10b7a9a3731f3fc8 X-Google-Attributes: gid1125fa,public X-Google-Thread: 1164f8,10b7a9a3731f3fc8 X-Google-Attributes: gid1164f8,public From: NRA@maxwell.ph.kcl.ac.uk (Nigel Arnot) Subject: Re: Alpha Dead? Naaahhhh.... (was Re: Is there a list of Alpha NT applications anywhere?) Date: 1997/12/19 Message-ID: <67dpjo$ml9$2@willow.cc.kcl.ac.uk>#1/1 X-Deja-AN: 308560177 References: <34915AEE.41C6@atlas.cheme.cornell.edu> <3491F2D7.28E3@videotron.ca> <3491FFE2.E1D71B82 Organization: Dept Physics, Kings College London Newsgroups: comp.os.ms-windows.nt.admin.misc,comp.os.ms-windows.nt.advocacy,comp.sys.dec,comp.os.ms-windows.nt.misc In article , Ketil Z Malde says: > >Dirk Grunwald writes: > >> This is the root of your problem. Just because code compiles doesn't >> mean it's 'legal'. Optimization can expose errors in your code due to > >Shouldn't a working compiler either: > > compile the program to working object code for all cases of > optimization and or debugging options >or > issue an error message to the effect that the program is illegal? > Some of these errors are fundamentally undiagnosable by a compiler. For example, suppose you have a routine in a DLL to zero out an array, someinthing like void zero( char *a, int n) { while (n>0) { *a++ = 0; --n; }} (out of my head, so assume it's correct even if it isn't) and it gets called by something you are compiling that does zero( mystuff, m*4) There's absolutely no way to check when the DLL was compiled that mystuff really is a pointer to m*4 chars, and there's no way for what you are compiling to know that m*4 is supposed to be the size of what mystuff is pointing at. So if you've made an error and mystuff is pointing to the wrong place in memory or m has the wrong value, something may get zeroed that shouldn't have been. In these circumstances it's quite probable that optimized and non-optimized code will behave differently. It's my experience that one more commonly sees a non-optimized version that "works" become an optimized one that doesn't. This probably simply reflects the fact that most programmers debug non-optimized versions first, because symbolic debuggers work best that way, and so if the bug had disrupted operation of the non-optimized version they'd have immediately looked for a programming error. If, however, something that has "worked" for months breaks when optimised, they tend to want to blame the optimizer. That's just human nature.