gcc bug: convert_move -O3

Reini Urban rurban@x-ray.at
Thu Jun 30 18:19:00 GMT 2005

Dave Korn schrieb:
> ----Original Message----
>>From: Gerrit P. Haase
>>Sent: 30 June 2005 12:10
>>>>static int hack30_pray(ax, items, func)
>>>>int ax;
>>>>int items;
>>>>void *func;
>>>>    return 0;
>>>>int main () {
>>>>  int ax, items;
>>>>  void * symref;
>>>>  float num;
>>>>  num = ((*((float (*)()) hack30_pray))(ax,items,symref));   return 0;
>>S.th. wrong with your testcase?
>   Absolutely.  There are two *VERY* bad things about that bit of code:
> 1)  The function call is through a pointer-to-function-returning float, but
> the function itself returns a void *.  This is likely to screw up the x87 FP
> stack when the caller pops a return value that the callee didn't push.

If it's really coming from the SP(0), which gcc obviously assumes 
(hard-floats) vs. some other cpu's/clib's return floats on eax 
(soft-floats) or just emulates the SP.

I'll write an extra function for the float case. Only gcc dislikes that.

> 2)  Also, the function call is through a pointer-to-function-taking-stdargs,
> but the function itself is not a stdargs function.  Given the wrong calling
> conventions, this is liable to lead to both caller *and* callee cleaning the
> args off the stack.....

Calling conventions should be determined at run-time who will pop the 
stack. Both DLL types should be able to be loaded. So the hack src 
should duplicate itself for both ways.
E.g. WinAPI (pascal = stdcall convention) will fail with the current 
hack30 library.

>   A name like 'hack*_pray' suggests that this is an ugly hack that the
> author was praying was going to work.....   I am obliged to agree!

Yes, that's the hairy hack30 trick from unknown old sources, which is 
used for several FFI's as last resort. ;-)
That's why I didn't want to fix perl Win32::API callbacks with that mess.

BTW: I fixed C::Dynalib now at least so we do have another working perl 
FFI with callbacks again.
Reini Urban

Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

More information about the Cygwin mailing list