[fpc-devel] Assignment to bitpacked record member that crosses byte boundary does not always work correctly (i386).

Jonas Maebe jonas.maebe at elis.ugent.be
Wed Jun 18 18:40:21 CEST 2008


On 17 Jun 2008, at 23:38, Jonas Maebe wrote:

> On 17 Jun 2008, at 10:56, <RusselD at denelaviation.co.za> <RusselD at denelaviation.co.za 
> > wrote:
>
>> The limited amount of testing done indicates that the record member
>> bit8_1 only causes a problem with a value of $FF, but the interesting
>> thing is that the result varies depending on program structure and
>> compiler version: Different results are seen whith the same code in a
>> procedure, in a 'with' statement, or if there is code in front of it
>> etc. The result is NOT always incorrect.
>
> The problem can occur both when assigning 0 and when assigning  
> field_type(-1). I'll look into fixing it tomorrow.

Fixed. Note that
a) your test programs were specific to little endian systems  
(bitpacked records have a different layout on big endian systems)
b) the internal layout of bitpacked records is not guaranteed to  
remain the same over different versions (although there are no  
particular intentions to change it either)
c) the second test program only defines 15 bits of the packed records,  
so in the tests when checking for expected results you have to mask  
out the left over bit (since it can contain garbage)
d) there was one error in the second test: if bit9_15 is set to one  
and the rest to 0, the value of AsWord should be $0200 rather than  
$0100.

Thanks for the good test programs!


Jonas



More information about the fpc-devel mailing list