Waldek wrote (in private mail, but I hope you don't mind me forwarding it to the list, as it concerns the current discussion about bitsizes):
I have noticed that fjf395[ab].pas expects to be able to compute on out of range values. Both of them fail with 4.1 backend. According to recent discussion on GCC list using out of range values is illegal (if we consider such values legal the type should have bigger bounds).
I would prefer to declare fjf395[ab].pas illegal and remove them from the testsuite. And say that user programs expecting such behaviour should be fixed.
Yes, the test programs are currently wrong as they put ordinal values > 1 in `Boolean attribute (Size = n)' variables. I wrote them at a time when semantics of `Boolean (n)' (as they were called back then) were not very clearly defined ...
The other solution is "double accounting", when we have types with loose bounds for backend use, but we separatly track ranges in the front end.
I'd prefer to avoid this, as it'd surely add quite some effort for probably little gain. In fact, as integer ranges can be freely declared, and we don't (yet) support bitsizes for types other than integers and Booleans, it seems to affect only Booleans with specified bitsize, which is a very special case.
So we have the choice either to leave the range at False {0} .. True {1}, and forbid other values, and change the test programs, or to really declare the range according to the bitsize (e.g. False {0} and 255 values of True for an 8 bit type).
The former would seem more Pascalish. OTOH, such types are probably often used for C interfaces, and what will happen if C routines put values > 1 in them? Probably undefined stuff (e.g., the backend would be free to check only bit 0 or byte 0), so we'd have to declare this invalid, which limits the use of these types.
With the latter, we'd get some strange semantics (such as `Ord (High (...))' of such types not yielding 1) -- or rather, we'd retain them, as some strange semantics are already there:
program Foo;
type t = Boolean attribute (Size = 8);
var a, b: t;
begin a := t (5); b := t (2); WriteLn (a); WriteLn (b); WriteLn (a = b) end.
Says:
True True False
And contrary to Adriaan's previous suggestion we'd actually need a pseudo-schema then, as `Boolean attribute (BitSize = 8)' according to his proposal would yield a 0 .. 1 range.
But still, the latter seems the lesser evil to me ATM, as otherwise these types might not be very useful at all ...
Or can/should we drop them altogether? Are they needed for Delphi compatibility? Or does someone seriously need them (where they can't just be replaced with bitsize-Integers, adding `<> 0' and `Ord' where necessary)?
Frank