APCS-32 & 'float' argument passing

Nick Burrett nick at dsvr.net
Thu Jun 10 10:51:14 PDT 2004

John Tytgat wrote:
> C Language Calling Conventions
> ------------------------------
> Argument Representation
> .......................
> A floating point value occupies 1, 2, or 3 words, as appropriate to its type.
> Floating point values are encoded in IEEE 754 format, with the most significant 
> word of a double having the lowest address.
> The C compiler widens arguments of type float to type double to support 
> inter-working between ANSI C and classic C.
> [...]
> --8<--
> I can only conclude GCC is not completely APCS-32 compliant.

I don't know where you got this document from, but it is wrong and as 
far as I am concerned, the Norcroft compiler is wrong.

Have a look at the APCS defined here:

   A floating-point value not passed in a floating-point register is
   treated as 1, 2 or 3 integer values, as appropriate to its precision.

I think the promotion of floats to doubles for argument passing is 
invalid and most probably broken.  I don't think the programmer is going 
to be happy with the compiler changing the underlying precision of the 
floating point variables that he has specified in the middle of a 

I would not like to imagine the rounding errors that this promotion from 
float to double for argument passing could cause.

For some reason Norcroft has changed it's calling conventions.  If it 
had always promoted floats to doubles, then the UnixLib code would have 
been written to take doubles.



More information about the gcc mailing list