question about assembly code

Olivier Maury Olivier_maury@mentor.com
Tue Aug 9 14:26:00 GMT 2011


Hi all,

I was wondering, is the following assembly code correct:
      c94:       e8 fc ff ff ff          call   c95 
<load_param_def_given+0x1d1>
      c99:       84 c0                   test   %al,%al
      c9b:       dd 45 d0                fldl   -0x30(%ebp)
      c9e:       dd 45 d8                fldl   -0x28(%ebp)
      ca1:       da c9                   fcmove %st(1),%st
      ca3:       dd d9                   fstp   %st(1)
      ca5:       dd 5d d0                fstpl  -0x30(%ebp)
      ca8:       89 f8                   mov    %edi,%eax

This code is some optimized assembly code extracted from the object file 
using objdump. My concern here is that I have a test instruction without 
the corresponding jump !

That piece of assembly comes from a code that look like:
if (my_function(param1, &out_param))
     value = out_param;

with :
out_param a double value that is not assigned with a default value
and
char my_function(long param1, double *out)
{
    char ret = 0;
     ... do some stuff ...
     if (some_property)
    {
        ... do some stuff ...
        *out = a_value_computed;
        ret = 1;
    }
    ....
    return ret;
}

And taking that optimized code in a debugger it crash with a FPE from 
time to time because even if the my_function returns 0 it seems to do 
the assignement (value = out_param) with an unitialized out_param value !

What do you think ? Am I doing something wrong or is it a gcc bug ?

Regards

Olivier



More information about the Gcc-help mailing list