In lcltypes.pp, alignment problem in tagBITMAPFILEHEADER
Original Reporter info from Mantis: MarkMLl @MarkMLl
-
Reporter name: Mark Morgan Lloyd
Original Reporter info from Mantis: MarkMLl @MarkMLl
- Reporter name: Mark Morgan Lloyd
Description:
In lcl/lcltype.pp
the definition
tagBITMAPFILEHEADER = packed record
bfType: Word;
bfSize: DWORD;
...
puts a 32-bit dword on a 16-bit word boundary, which on a processor which is strict about alignment raises an exception on the second call to swap() in bitmap.inc
{$IFDEF ENDIAN_BIG}
swap(Header.bfType);
swap(Header.bfSize); // EXCEPTION HERE
//swap(Header.bfOffBits);
{$ENDIF}
This definitely affects SPARC and possibly affects others, at the very least it might have performance implications.
Steps to reproduce:
Build and run cd_test_all.
Additional information:
I was able to fix this by putting in a dummy word, which makes SPARC behave in the same way as PPC on this test.
According to some, the Solaris kernel handles alignment errors. I don't see this happening, and speculate that it's actually in libc.
Mantis conversion info:
- Mantis ID: 27761
- OS: Any
- Build: Using FPC 2.7.1
- Platform: SPARC, possibly others
- Version: 1.5 (SVN)