Weird porting problem with read

Background: I'm working on porting GHC to IA64. I have the initial unregisterised port mostly working, except for a weird problem related to this innocent bit of code (ghc/compiler/main/CmdLineOpts.hs): opt_HiVersion = read (cProjectVersionInt ++ cProjectPatchLevel) :: Int where: cProjectVersionInt = "503" cProjectPatchLevel = "0" I get... ghc-5.03: panic! (the `impossible' happened, GHC version 5.03): Prelude.read: no parse Possibly of relevance is that cProjectVersionInt is built using unpackCStringList#, whereas cProjectPatchLevel was generated statically. Below I've included an ASCII art depiction of the closure that is passed to read, after evaluation (i.e. I breakpointed after the parse error). It looks feasibly correct to me, although I may be missing something. Does anyone have any hints on where to proceed from here? Matt CmdLineOpts_lvl42_closure IND_STATIC(0x504af380) | IND(0x504af418) | CONSTR(GHC.Base_C_con_info(tag=1), 0x504af3d8, 0x504af400) | | CONSTR(GHC.Base_C#_con_info(tag=0), 0x35#) | _____________________| | IND(0x504b0018) | CONSTR(GHC.Base_C_con_info(tag=1), 0x504affc8, 0x504b0000) | | CONSTR(GHC.Base_C#_con_info(tag=0), 0x30#) | _____________________| | IND(0x504b09f0) | CONSTR(GHC.Base_C_con_info(tag=1), 0x504b09b0, 0x504b09d8) | | CONSTR(GHC.Base_C#_con_info(tag=0), 0x33#) | _____________________| | IND(Config_cProjectPatchLevel_closure) | CONSTR(GHC.Base_C_static_info(tag=1), Config_a_closure, GHC.Base_[]_closure) | | CONSTR(GHC.Base_C#_static_info(tag=0), 0x30#) | __________________________| | CONSTR(GHC.Base_[]_static_info(tag=0))

Well, I figured it out myself in the end... it's gcc dodginess :/ numberToInt checks the number that's been read against minBound :: Int. In the 64-bit STG C code this ends up being: _Cak7_=(-9223372036854775808)<=(I_)(R1.p[1]); If I were to read the gcc warnings it would say: Text/Read/Lex.hc:40: warning: decimal constant is so large that it is unsigned and it seems to make a dodgy optimisation on that basis. If I change the constant to -(2^63-1) instead of -2^63 it works, and without the warning message. Which seems like a compiler bug to me, since -2^63 is a valid 64-bit signed number. I'll see what the gcc folks have to say. Matt
participants (1)
-
Matt Chapman