From: Endlisnis Newsgroups: comp.os.msdos.djgpp Subject: Re: Am I retarded -or- Why is my exe size so big?!? Date: Sun, 30 Aug 1998 12:21:05 -0300 Organization: NBTel Internet Lines: 48 Message-ID: <35E96DE1.76D4B53B@unb.ca> References: NNTP-Posting-Host: fctnts12c40.nbnet.nb.ca Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Eli Zaretskii wrote: > > > Actually it states that -O2 is the best optimizations switch without a > > > speed/size tradeoff. > > But, -O1,2 or 3 sometimes make programs that don't do what you might > > expect/desire. I have a few VERY LONG programs that do not do the same stuff > > when compiled with any optimizations on. They are fully ANSI compilent > > programs not trying to do anything tricky. > > It is a bug when a program behaves differently under different > optimization switches. Usually, the bug is in the application code, > not in the compiler. Unless these programs explore the fine details > of machine arithmetics, which AFAIK is the only case when > optimizations should NOT be used, you need to debug those programs, > I'd say. Well, I run everything through RHIDEv1.4, and for some reason, the debugger won't touch my code. It just skips right to the end. And even if I convince it to walk through parts of my code, I can't watch half the variables. When I'm in the correct context for that variable, it still says "Not Avaiable". On a slightly different subject, here's a line of code which doesn't do what I expect (under any optimization level including none): #include typedef unsigned int lword; int main() { short* DOS = 0xC0001234; //C000:1234 = 000C1234 linear address DOS = (short*)(((lword)DOS>>12)&0xFFFF0)+((lword)DOS&0xFFFF); cout << DOS << " should be 0xC1234\n"; return 0; } Output: 0xc2468 should be 0xC1234 This is a shortend version of code that needs to get data from an SVGA function that returns SEG:OFFSET info and I need to convert it to a linear address. If I use a temporary variable of type 'lword', and do the exact same line of code (without the casting) it works perfectly. -- (\/) Endlisnis (\/) s257m AT unb DOT ca Endlisnis AT GeoCities DOT com Endlis AT nbnet DOT nb DOT ca