<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">El 29/04/2018 a las 19:38, Vojtěch
Čihák via Lazarus escribió:<br>
</div>
<blockquote type="cite" cite="mid:20180429193838.EEACB7EE@atlas.cz">
<p style="padding:0 0 0 0; margin:0 0 0 0;">Hi,</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">I changed line 7:</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">TElement = record</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> strr: String;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> end;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> TList = array[0..1]
of TElement; //HERE</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> Plist = ^TList; </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">and demo works.
Simply, static and dynamic arrays are not the same.</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">AFAIR, dynamic array
is just pointer while static array are data.</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">I guess someone else
will give you more detailed answer.</p>
</blockquote>
<br>
<br>
Yes, but I think that it should be considered a FPC bug<br>
<br>
TList = array of TElement;
<br>
Plist = ^TList;
<br>
<br>
TSetting = record
<br>
list: Plist;
<br>
end;
<br>
<br>
const
<br>
_List: array [0..1] of TElement = (
<br>
(strr: 'a'),
<br>
(strr: 'b'));
<br>
<br>
_Settings: array [0..0] of TSetting = ( <br>
(list: @_List));
//
<=== This line should rise a compiler error. You are asigning a
pointer to an static array to a pointer to a dynamic array.<br>
<br>
-------------------<br>
You could add a type cast of the pointer to Plist<br>
<br>
_Settings: array [0..0] of TSetting = ( <br>
(list: Plist(@_List) ));
<br>
<br>
You explicitly tell the complier to bypass type check, it is up to
deal with this potential dangerous <br>
<br>
<br>
<br>
<br>
<blockquote type="cite" cite="mid:20180429193838.EEACB7EE@atlas.cz">
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">V.</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">______________________________________________________________<br>
> Od: Valdas Jankūnas via Lazarus<br>
> Komu: <a class="moz-txt-link-abbreviated" href="mailto:Lazarus@lists.lazarus-ide.org">Lazarus@lists.lazarus-ide.org</a><br>
> Datum: 29.04.2018 18:16<br>
> Předmět: [Lazarus] Runtime error: INCLOCKED<br>
></p>
<br>
type<br>
TElement = record<br>
strr: String;<br>
end;<br>
TList = array of TElement;<br>
Plist = ^TList;<br>
.....<br>
<br>
Why I getting that error? Something wrong with records and
constant initialization?<br>
<br>
My system is: Linux 4.13.0-39-generic #44-Ubuntu SMP Thu Apr 5
14:25:01 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux<br>
FPC (from SVN): 3.1.1 [2018/02/21] for x86_64<br>
-- <br>
Valdas Jankūnas<br>
-- <br>
_______________________________________________<br>
Lazarus mailing list<br>
<a class="moz-txt-link-abbreviated" href="mailto:Lazarus@lists.lazarus-ide.org">Lazarus@lists.lazarus-ide.org</a><br>
<a href="https://lists.lazarus-ide.org/listinfo/lazarus"
moz-do-not-send="true">https://lists.lazarus-ide.org/listinfo/lazarus</a><br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
</blockquote>
<p><br>
</p>
<pre class="moz-signature" cols="72">--
Saludos
Santiago A.
</pre>
</body>
</html>