<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 13/08/2018 02:32, Martin wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:8d3f1481-af8b-9dcb-b85b-8effdd2074d3@mfriebe.de">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <div class="moz-cite-prefix">On 13/08/2018 00:12, Dmitry
        Boyarintsev wrote:<br>
      </div>
      <blockquote type="cite"
cite="mid:CAMpTZrcmmDkywyGGq+3u1SowL=k2XqxOTCGA5JO=Baa7qKRx3w@mail.gmail.com">
        <meta http-equiv="content-type" content="text/html;
          charset=utf-8">
        <div dir="ltr">
          <div class="gmail_quote">
            <div dir="ltr">On Sun, Aug 12, 2018 at 5:40 PM Bart <<a
                href="mailto:bartjunk64@gmail.com"
                moz-do-not-send="true">bartjunk64@gmail.com</a>>
              wrote:<br>
            </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">const<br>
                x = ShortString('abc');<br>
              begin<br>
                writeln(SizeOf(x));<br>
              end.<br>
              <br>
              Delphi (7) prints 256, fpc prints 3.<br>
              <br>
              Is that a bug or an implementation detail?<br>
            </blockquote>
            <div> </div>
            <div>Implementation detail.</div>
            <div>And it seems to be wrong on Delphi size, because for
              reason it assigns a type to a (non-typed) constant.</div>
            <br>
          </div>
        </div>
      </blockquote>
      Interesting.<br>
      <br>
      Yet the compiler still seems to add some type or at least type
      specific behaviour. (That alone is ok)<br>
      <br>
      But if the first string has the length in a[0], then that constant
      has 6 bytes of data. Yet sizeof only reports 5.<br>
      So what is the real size of this constant?<br>
      <br>
      <br>
      program Project1; {$H+}<br>
      const<br>
        a = 'abcde';<br>
        b = 'abcde
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890';<br>
      begin<br>
        writeln(SizeOf(a)); // 5<br>
        writeln(SizeOf(b)); // 5<br>
    </blockquote>
    copy and paste, this on prints the length of b<br>
    <blockquote type="cite"
      cite="mid:8d3f1481-af8b-9dcb-b85b-8effdd2074d3@mfriebe.de">  
      writeln(byte(a[0]));  // no range check / shortstring has index 0
      with length<br>
        writeln(byte(b[0])); // range check / not a shortstring<br>
        readln;<br>
      end.<br>
      <br>
      <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>