Martin Liddle wrote:
In article 200112030149.CAA20486@goedel.fjf.gnu.de, Frank Heckenbach frank@g-n-u.de writes
Again, the test program was quite necessary. The bug was in the interface (GPI) mechanism, and just happened to affect packed records (and possibly other things as well, though I haven't observed any). (martin2a.pas, and martin2b.pas for an even simpler example that showed the bug)
Patch attached (though it was made against otherwise modified sources; if you can't apply it, you'll have to wait for Peter's next upload).
Also I am a bit puzzled that the build also stopped, complaining that bison wasn't installed (which was true) but it hadn't been required previously.
The bison generated files (parse.[ch]) are supplied with source distributions (not CVS). My patched changed the source (parse.y), so bison was needed to regenerate them (I could have sent patched for them as well, of course, but I didn't think of it, since I usually only make patches of the real sources.)
BTW, this part of the patch only dealt with the `class' issue (another thread), so it would have been safe to skip it (touch parse.[ch]).
However, testing martin2a.pas on Sparc and MIPS revealed another problem. These processors (as typical for RISCs) have strict alignment requirements for word accesses, e.g., they can't read 32-bit values from addresses not divisible by 4. The set field of the (now really) packed record is not at an aligned address, and the RTS set routines do word access.
I see the following possible solutions:
- Always align sets in packed records. This would break your binary files again.
- Do it only on platforms with alignment requirements. This would increase the binary file incompatibilty between platforms. They're now not fully compatible due to endianness, but such a change would add another important issue which would not be easy to work around (i.e., it would be almost impossible to use such binary files in a platform-independent way).
- Change the RTS set routines to byte accesses. That's easy to do (and has been discussed here some months ago), but would decrease the efficiency.
- Let the RTS set routines check (on each invocation) if access is aligned. If not (and the platform requires it), use special code (like for packed arrays); otherwise use the faster word access.
Frank