[fpc-devel] Wrong docs: not initialized global variables
Ondrej Pokorny
lazarus at kluug.net
Wed Apr 4 20:26:29 CEST 2018
On 04.04.2018 20:03, Jonas Maebe wrote:
> On 04/04/18 19:32, Ondrej Pokorny wrote:
>> On 04.04.2018 18:53, Jonas Maebe wrote:
>>> On 04/04/18 18:44, Ondrej Pokorny wrote:
>>>> I want to stress that the compiler emits a warning on code that
>>>> does not have (and also cannot have) an error
>>>
>>> An error is wrong code behaviour. If you do not initialise a
>>> variable with the correct value, then you can have an error.
>>
>> No, no, no and again no. Do you try to convince me that I cannot rely
>> on well documented compiler behavior?
>
> No. You replied to the above sentence out of context. The context was
> given in the next sentence:
>
>>> This correct value can be different from "empty string" or "nil".
No, I replied perfectly within the context. Read again:
Myself: "I want to stress that the compiler emits a warning on code that
does not have (and also cannot have) an error".
You: "An error is wrong code behaviour. If you do not initialise a
variable with the correct value, then you can have an error. This
correct value can be different from "empty string" or "nil"."
The compiler initializes the variable implicitely for myself - this is
documented and I know it. There cannot be "wrong code behaviour" (as you
stated) and thus I cannot have an error. This is simple logic.
With your logic I should get a warning all over the code. Even after an
assignment:
I := 5;
The compiler may think that 5 is not the correct value I want there?
Maybe it should warn me that I wanted a 6 there? The warning could
state: "An error is wrong code behaviour. If you do not initialise a
variable with the correct value, then you can have an error. This
correct value can be different from "5"."
>> If I want to have a different value from "empty string" or "nil" I
>> know I have to initialize it by myself. I don't need a warning for it.
>
> Then turn it off.
I must not. Turning off warnings is forbidden. Turning off hints and
notes is OK. That is the rules.
Please do not get me wrong - I am perfectly fine that the compiler emits
a message in this case. But I am not fine with the fact that the level
of this message is a WARNING - the same level that real code errors are
reported.
Ondrej
More information about the fpc-devel
mailing list