[fpc-pascal] Error: Can't take the address of constant expressions

Jonas Maebe jonas.maebe at elis.ugent.be
Wed Sep 26 10:29:59 CEST 2012

On 26 Sep 2012, at 07:58, Vincent Snijders wrote:

> 2012/9/25 Bernd <prof7bit at gmail.com>:
>> 2012/9/25 patspiper <patspiper at gmail.com>:
>>> procedure test;
>>> begin
>>>  Move(MyClass1.Ref.Data^, MyClass2.Ref.Data^, 1);
>>> end;
>> and if you cast it to some other pointer type before dereferencing the
>> error goes away:
>> procedure test;
>> begin
>>  Move(MyClass1.Ref.Data^, PByte(MyClass2.Ref.Data)^, 1);
>> end;
>> But this should not be necessary.
> Why not?  The error is correct. By using the type cast you tell the
> compiler you know what you are doing and that is should not bother
> doing the sanity check.

If that were true, then using a local variable that is an untyped pointer would also have to fail. It is in fact a compiler bug.


More information about the fpc-pascal mailing list