From: "DeHackEd" Subject: Optmization and Exceptions Date: Thu, 25 Dec 1997 19:27:48 -0500 Lines: 44 Message-ID: Newsgroups: comp.os.msdos.djgpp To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I was just playing around with the C++ compiler and I noticed a few things: 1) Without optmizations, strlen("string literal") evaluates to asm LC1: .ascii "string literal\0" pushl $LC1 call _strlen But with -O3, it just evaluates to $14 (I think - I can't count). 2) With or without optmizations, (12*5) evaluates to $60, not a long asm output for calculating it. This is something which came up as a problem on some newsgroup. 3) Exceptions often cause the compiler to have an internal compiler error message. Take a look at a simple program like this (I know I am using C, not C++, screen routines, but it makes the output much nicer) #include main() { printf("About to throw something\n"); try { printf("In try..."); throw "Strike 1"; } catch (char *msg) { printf("Caught something: %s\n", msg); exit(1); } catch (int num) { printf("Error %d\n", num); exit(num); } } // This program does not link if -O3 compiled! Can you find the error? // And you need to link in -lstdcx