RE: Weird porting problem with read

2002-05-06 Thread Simon Marlow


> 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.

I've had similar problems before with minInt.  I seem to recall that the
C standard doesn't guarantee that this constant is representable in the
int type: I think it has to do with the fact that the C standard doesn't
proscribe 2's complement arithmetic, and in 1's complement you can't fit
-2^63 in an int.

Cheers,
Simon
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Re: Weird porting problem with read

2002-05-05 Thread Matt Chapman

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

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Weird porting problem with read

2002-05-05 Thread Matt Chapman

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, 0x504b)
   |   |
  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))

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users