Prof A Olowofoyeku wrote:
It is with the "move" call that I actually don't need the compiler complaining about dereferencing untyped pointers.
I guess in general you mean dereferencing untyped pointers to pass then via var parameters. We could in principle allow such use while disallowing all other uses, trough it is somewhat tricky to do in the compiler (at first glance it looks almost impossible, but I have found rather simple way to do this). Still, such use should be not very frequent.
One option was to have "{$borland-pascal}" and such before the call, and then have "{$gnu-pascal}" afterwards to turn off the BP mode. However, this now breaks other things: e.g.,
function foo (const p; size : cardinal) : Integer; begin [...] inc (count); {$delphi} move (p, values^[count]^, size); { will now compile } {$gnu-pascal} result := count; end;
The assignment to "result" will no longer compile, whatever you pass at the command line, because under GPC 20050331, "{$gnu-pascal}" means that "result" is no longer predefined :-(
In the example above, "result" will be accepted if you pass "--implicit- result" to the compiler. It will however, only be accepted inside that function. It will be rejected in any other function that comes thereafter - e.g.,
function bar : integer; begin result := 0; (* not accepted because of the {$gnu-pascal} above *) end;
It compiles with my GPC 20050331, but I consider this as a bug. The preferred method is:
{$local delphi} move (p, values^[count]^, size); { will now compile } {$endlocal}
the `{$endlocal}' directive should restore the exact setting in force before `{$local'. It still does not work with my GPC 20050331, but I consider this as a bug (which I hope will be quickly fixed). I do not know why you consider here compiler directives better then
move (p, pchar(values^[count])^, size); { will now compile }
BTW if you want to use `move' multiple times, did you consider defining a new routine with second parameter beeing a pointer (so there is no need to dereference):
procedure movevp(const s; tp: pointer, size : cardinal); begin move (p, pchar(tp)^, size); end;
and later:
movevp (p, values^[count], size);
Let's just say that this new feature has made life more difficult for me, since before the 20050331 snapshot, {"$gnu-pascal}" meant "allow everything that GPC supports". Now, it seems to mean something different. I am not sure whether this is an unintended side effect, but it does look like it to me!
`{$gnu-pascal}' means "allow everything that GPC supports and does not conflict with default settings". It was explained that `implicit-result' is _not_ an extension, it is an incompatible change. Key here is that an extension assigns meaning to otherwise illegal construct (so all old programs continue to work). `implicit-result' changes meanig of non-Delphi programs. If Wirth says that a program should print 1 and Delphi prints -1 than we can not support both ways as a default (and we like Wirth more than Delphi:)