id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	os	architecture	failure	difficulty	testcase	blockedby	blocking	related
5423	Registers above R8 corrupt when called through prim import	pumpkin	igloo	"I write a cmm function:
{{{
primbug
{
  foreign ""C"" printf(""%d %d %d %d %d %d %d %d %d\n"", R1, R2, R3, R4, R5, R6, R7, R8, R9);
  RET_N(R9);
}
}}}

and a binding to it in Haskell:
{{{
foreign import prim ""primbug"" primbug :: Int# -> Int# -> Int# -> Int# 
                                      -> Int# -> Int# -> Int# -> Int#
                                      -> Int#
                                      -> Int#

-- This should resemble id
bug :: Int -> Int
bug (I# i) = I# (primbug 0# 111# 222# 333# 444# 555# 666# 777# i)

main = print (bug 888)
}}}

and the program outputs:

{{{
0 111 222 333 444 555 666 777 0
0
}}}

The contents of R9 have been lost somehow! The result of this corruption isn't always 0, if that helps track it down: in my more complicated use case, I'm getting smallish numbers (two hex digits) instead of a legitimate pointer.

I'm attaching a small cabal package to help reproduce it, because it's a pain to build."	bug	closed	high	7.4.1	Compiler	7.2.1	fixed		ekmett@…	Unknown/Multiple	Unknown/Multiple	None/Unknown					
