<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><a class="moz-txt-link-freetext" href="https://www.freepascal.org/docs-html/ref/refse20.html#x50-680003.9">https://www.freepascal.org/docs-html/ref/refse20.html#x50-680003.9</a></p>
<br>
<div class="moz-cite-prefix">On 04/04/2018 01:32 PM, Ondrej Pokorny
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:fe8ea7ad-cbbf-7bbc-5f01-6cd84bda91b9@kluug.net">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div class="moz-cite-prefix">On 04.04.2018 18:53, Jonas Maebe
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:93245b4c-8f2f-3399-3220-e942f1849269@freepascal.org">On
04/04/18 18:44, Ondrej Pokorny wrote: <br>
<blockquote type="cite">I want to stress that the compiler emits
a warning on code that does not have (and also cannot have) an
error <br>
</blockquote>
<br>
An error is wrong code behaviour. If you do not initialise a
variable with the correct value, then you can have an error.</blockquote>
<br>
No, no, no and again no. Do you try to convince me that I cannot
rely on well documented compiler behavior? Even Sven stated
earlier in this thread that the FPC docs are correct in case of
managed variables: "Managed types are an exception to this rule:
Managed types are always initialized: in general this means
setting the reference count to zero, or setting the pointer value
of the type to Nil." and "It should be stressed that initialized
variables are initialized when they come into scope" <a
class="moz-txt-link-freetext"
href="https://www.freepascal.org/docs-html/ref/refse24.html"
moz-do-not-send="true">https://www.freepascal.org/docs-html/ref/refse24.html</a><span
style="color: rgb(0, 0, 0); font-family: "Times New
Roman"; font-size: medium; font-style: normal;
font-variant-ligatures: normal; font-variant-caps: normal;
font-weight: 400; letter-spacing: normal; orphans: 2;
text-align: start; text-indent: 0px; text-transform: none;
white-space: normal; widows: 2; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration-style: initial;
text-decoration-color: initial; display: inline !important;
float: none;"></span><br>
<br>
Again, the code<br>
procedure Test;<br>
var S: string; I: Integer;<br>
begin<br>
for I := 0 to 1 do<br>
S := S + '1';<br>
Writeln(S);<br>
end;<br>
<br>
does not have an error, cannot have an error and the behavior is
guaranteed and well documented => no warning should be here.<br>
<br>
+ Do you try to convince me that the code below can have an error
and should emit a warning as well because it does not initialize
the FS and FI fields?<br>
<br>
program Project1;<br>
type<br>
TMyObject = class<br>
private<br>
FS: string;<br>
FI: Integer;<br>
public<br>
property S: string read FS write FS;<br>
property I: Integer read FI write FI;<br>
end;<br>
<br>
begin<br>
with TMyObject.Create do<br>
begin<br>
Writeln(S);<br>
Writeln(I);<br>
Free;<br>
end;<br>
end.<br>
<br>
It's the same case - object fields are documented to be
initialized. You mean I should not rely on this feature and it is
an error that I did not initialize them with the correct values?<br>
<br>
<blockquote type="cite"
cite="mid:93245b4c-8f2f-3399-3220-e942f1849269@freepascal.org">This
correct value can be different from "empty string" or "nil". </blockquote>
<br>
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.<br>
<br>
<blockquote type="cite"
cite="mid:93245b4c-8f2f-3399-3220-e942f1849269@freepascal.org">For
the same reason, we also warn about uninitialised global
variables (if this can be detected without interprocedural
analysis, i.e., if they are only used in the main program code;
but that is merely due to a limitation of the analysis).</blockquote>
<br>
Uninitialised global variables are the same case: the compiler
should not emit a warning here because again, it is well
documented that they are implicitely initialized (at least in the
Object Pascal Language Guide from Borland from 2002 it is
documented).<br>
<br>
Ondrej<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
fpc-devel maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a>
</pre>
</blockquote>
<br>
</body>
</html>