Mail Archives: djgpp/1997/12/26/05:19:24
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 <stdio.h>
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
- Raw text -