Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2006-10

Re: fpc-pascal Digest, Vol 26, Issue 9

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Alexander Todorov
Michael Van Canneyt wrote 17 lines
> 1) If the Flag field is set to true and the programmer uses field from > the variant part which is declared in the false section, should there > be a run time error or not? No. No checking is performed on this. > Although it will be slowly should the compiler check V.Flag and > consider the other fields undefined? Something like "Inaccessible > record field used" error? No. The 'Flag' field is purely informational and has no restrictive meaning. It's a hint to the programmer, but nothing more. This is how pascal is defined. Michael.

Thanks for the explanation Michael.
Maybe it will be good these lines to be added in the FPC docs for reference to newbies.

Jonas Maebe wrote 15 lines
> 2) In the test program the addresses of the two fields are the same > due to the default aligning used by the compiler. That's why the > output is the number 100. > In Delphi these addresses differ in 1 byte, so the ouput is : > V.Flag=FALSE, V.false_1=100, V.true_1=200 > V.Flag=TRUE, V.false_1=100, V.true_1=200 > Is this by design or FPC has an inconsistency with Delphi? Both. All components of the variant part of a record always start at the same address by design (because it avoids changing the overlapping of the variant fields depending on the packrecords setting), and apparently this is different in Delphi. Jonas

Should this difference with Delphi considered a bug or not? IMO this is not a bug.
Are there docs for the compiler desing and it's implementation of the Pascal language?
I admit I haven't searched the site for that. Such differences should be documented somewhere.