range check 32-bit and 64-bit

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Apr 10 09:07:47 CEST 2007

On 10 Apr 2007, at 08:52, Jonas Maebe wrote:

> Note that doing this may cause problems with packed arrays and  
> records, like we had in FPC. If you treat 0..3 as signed, then you  
> can no longer pack it in 2 bits using the current format used by  
> FPC and GPC. The reason is that if a type is signed, both compilers  
> treat the uppermost bit of a packed value as the sign bit. So 2 and  
> 3 would be interpreted as -2 and -1, respectively.
> Of course, it is possible to change the format of packed values  
> (e.g., always store them as unsigned, with a bias of -lower_bound  
> in case of signed types), but this may cause backward compatibility  
> issues.

Or, alternatively, you can of course do the sign extension only if  
the lower bound is < 0 rather than if the type is signed (maybe that  
even already happens today in gpc that way). Depending on how the gpc  
internals work, differentiating between "signed type" and "lower  
bound < 0" may cause some hairiness.

It's mainly something you simply have to keep in mind when performing  
such a change, I guess.


More information about the Gpc mailing list