Frank Heckenbach wrote:
Adriaan van Os wrote:
Still I am not convinced that
theIntPtr:= IntPtr( theBytePtr); {testcast.pas:11: warning: cast increases required alignment of target type}
should produce a warning and left-side equivalent shouldn't
BytePtr( theIntPtr) := theBytePtr;
Both statements have the same effect. Actually, the target is in both cases a variable of type Integer. So, at the left side of an assignment, the target is the innermost type of the cast, not the outermost.
I see. I'm adding a warning here (avo9.pas).
OK.
The same remarks apply for
theBytePtr:= BytePtr( theIntPtr); IntPtr( theBytePtr):= theIntPtr; {testcast.pas:14: warning: cast increases required alignment of target type}
but then the other way round.
It's more tricky to suppress the warning here since at the time the cast is built, the compiler doesn't know whether it will be used on the LHS or RHS. And since there's an easy alternative (RHS cast) available which is even preferable (LHS casts generally are a strange beast) and a compiler directive to turn of the alignment warnings, I don't think we need to bother.
OK, but I suggest to change the wording to "cast may increase required alignment of target type".
Regards,
Adriaan van Os