[fpc-pascal] Error: Can't take the address of constant expressions
Bernd
prof7bit at gmail.com
Tue Sep 25 19:18:42 CEST 2012
2012/9/25 patspiper <patspiper at gmail.com>:
> Hi,
>
> Despite
> http://wiki.freepascal.org/User_Changes_2.4.0#Treating_direct-mapped_properties_as_regular_fields,
> shouldn't the following be legal? I tested under FPC 2.6.1 and 2.7.1.
This shouldn't even matter here since IMHO it should work even if Ref
were a function (and it works if Ref is a function), it should always
work as long as the expression before the ^ is a pointer type.
And interestingly this works also (as it should):
type
TMyClass = class
private
FRef: Pointer;
public
property Ref: Pointer read FRef write FRef;
end;
var
MyClass1, MyClass2: TMyClass;
procedure test;
begin
Move(MyClass1.Ref^, MyClass2.Ref^, 1);
end;
but
Move(MyClass1.Ref, MyClass2.Ref, SizeOf(TMyClass.Ref));
will give an error (as it should), no matter how its internally
represented because the code that is using this property should not be
expected to make assumptions about internal compiler optimizations, it
should always treat it like a property.
But your example should work, IMHO you have found a bug.
More information about the fpc-pascal
mailing list