Re: [fpc-pascal] Error: Argument cannot be assigned to
On 04/06/2023 15:04, Juha Manninen via fpc-pascal wrote: Why the following code fails to compile? TMyRec = record ... property RecInstance: TMyRec read fRecInstance;// write fRecInstance; ... MyObj.RecInstance.ii := 123; Access through property seems to be the problem. Accessing fRecInstance directly works. A property enforces that any code you write will work even if you change the property to a getter/setter. Or in other words, it will fail any code that would not work. If this was a getter, it would be function GetRec: TMyRec; And that returns a *copy* in a temporary location of the record. Technically you can modify the members of the temp record (just to have the work thrown away afterwards). So I guess the compiler forbids it, because the only case it would ever be done is: by mistake. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] What is -CO ?
On 09/06/2023 12:03, Mattias Gaertner via fpc-pascal wrote: Hi, What is -CO? In the docs I can only find this sentence: "Check for possible overflow of integer operations" Done some testing. -CO produces the below warning. program Project1; var a,b: Integer; var c: integer; begin a := Random(); b := Random(); c := a +b; // project1.lpr(7,3) Warning: Type size mismatch, possible loss of data / range check error writeln(c); end. However it overdoes it. make it var a,b: shortInt; Then the ":=random" will warn => ok. But the addition still warns, yet it can't ever fail. (even if the compiler internally uses int64) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal