Adriaan van Os wrote:
I know that the Pascal Standard forbids taking the address of a field in a packed record. However, from a practical point of view I have always felt this is a rather clumsy restriction, unless of course the address is not byte aligned. Some Pascal implementations take the pragmatic course and allow taking the address of a field in a packed record if it is byte aligned. Is there any compelling reason why we should not allow this, except in Standard or Extended Pascal mode ?
Address have to be properly aligned. Unaligned reference may couse crash (some RISC machines, notably SPARC and AFAIK early PPC) or data corruption (ARM). If the backend belives that data is aligned it may generate fullword access even for characters (when copying arrays). So GPC would have to duplicate backend checks and accept/reject program depending on target characteristics. ATM I can not say how hard would be to implement such behaviour, but the end result look really like a loss:
1) program correctness would depend on rather on rather complex platform dependent alignment rules
2) program portability would decline
3) small modifications to data layout would convert valid program into invalid one
IMHO it much better to restructure the program. For example just use auxilary variable and copy the field (or pack/unpack the whole record) when needed.