title: E1012 Constant expression violates subrange bounds ; why does it work with variable?
body: <p>program Project1;</p>
  
  <pre><code>{$APPTYPE CONSOLE}
  
  {$R *.res}
  
  uses
    System.SysUtils;
  
  var
    ints: array[1..2] of Integer = (0,0);
    i   : Integer;
  
  begin
    ints[5] := 10;    // doesn't compile
    i := 5;
    ints[i] := 10;    // Seems to works
    Writeln(ints[i]); // and even display the value
    Readln;
  end.
  </code></pre>
  
  <p>I have set a bound to the array <code>ints</code>.</p>
  
  <p>Usually, I check the <code>Low(ints)</code> and <code>High(ints)</code> before trying to set a value to a bounded array...
  But as I was looking to another piece of <a href="https://stackoverflow.com/questions/10598365/checking-if-character-is-newline">code</a>, I notice that I can use index outside from the boundary and that it doesn't raise any exception...</p>
  
  <p>I'd like to know why it works and what are the consequence?
  (for example, if this part of memory is not <em>reserved</em> and I can corrupt it, ...)</p>
  
  <p>I have searched for others questions but haven't found the good one... if it's exist, do not hesitate to put the link and close this one, thanks.</p>