Compiling code that returns doubles with -finstrument-functions is broken. This does not depend on -O or -g flags. This program: double function (void) { return 10.0; } int main(void) { double d = function (); printf ("res: %f\n", d); } outputs: res: nan Here is the generated code: function: pushl %ebp movl %esp, %ebp pushl %esi pushl %ebx subl $16, %esp subl $8, %esp pushl 4(%ebp) pushl $function call __cyg_profile_func_enter addl $16, %esp movl $0, %ebx movl $1076101120, %esi subl $8, %esp pushl 4(%ebp) pushl $function call __cyg_profile_func_exit addl $16, %esp movl %ebx, -16(%ebp) movl %esi, -12(%ebp) fldl -16(%ebp) leal -8(%ebp), %esp popl %ebx popl %esi popl %ebp fstp %st(0) ret Everything seems peachy, except the last "fstp %st(0)" which just throws away the calculated result. This is pretty bad. I regulary use -finstrument-functions to profile Mozilla and other things.
I have fixed this in my tree, am just bootstrapping CVS gcc with it before submitting it to gcc-patches. It will appear later on in gcc-2.96-79.
Oops, forgot to close this. It was really fixed in 2.96-79 and above.
Fix confirmed in gcc-3.3.2-1.