[fpc-devel] const param documentation

Michael Van Canneyt michael at freepascal.org
Wed Oct 11 14:09:42 CEST 2017



On Wed, 11 Oct 2017, Martin wrote:

> https://www.freepascal.org/docs-html/current/ref/refsu67.html#x179-20100014.4.4
>
> Just came to notice something....
>
> But first: I had been under the impression, that if you
> - define a param as const
> - pass a global variable
> - violate the contract, by modifying the global var while in the scope 
> of the const param
> then you have written invalid code, and should expect the behaviour of 
> such code to be undefined.
>
> On the link above it gives an example of such a situation (changing the 
> content of  a string).
> The example shows the current implemented behaviour. (the new value is 
> assigned to the const param, and the new value is used).
>
> The documentation states: "This behaviour is by design"
>
> That means according to the doc, such use of a constant param has a 
> defined and documented behaviour, and is a valid use case?
>
> Should it not document, that it may print either value, or crash, or do 
> something else?
> Meaning "By design this code is invalid, and has no defined behaviour"

What is meant is that the behaviour of the compiler is by design.


I will change the wording.

Michael.


More information about the fpc-devel mailing list