Skip to content

PowerPC 64-bit: Foreign functions with more than 8 float parameters broken

Consider the following:

void many_floats(float f1, float f2, float f3, float f4, float f5,
                 float f6, float f7, float f8, float f9, float f10,
                 float f11, float f12, float f13, float f14) {
  printf("%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n",
	 f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14);
}

and

foreign import ccall "many_floats" many :: CFloat -> CFloat ->
     CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat ->
     CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> IO ()
main = many 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5 9.5 10.5 11.5 12.5 13.5 14.5

gives

1.500000
2.500000
3.500000
4.500000
5.500000
6.500000
7.500000
8.500000
0.000000
0.000000
3.000000
14.500000
13.500000
0.000000

on PowerPC 64-bit Linux.

According to the ABI for PowerPC 64-bit ELF v1.9 and ELF v2.0 the first 13 floating or double parameters are passed in floating point registers.

Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (NCG)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC erikd, hvr
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information