aboutsummaryrefslogtreecommitdiffstats
path: root/docs/LangRef.html
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-06-24 17:22:57 +0000
committerChris Lattner <sabre@nondot.org>2005-06-24 17:22:57 +0000
commite67a951720caa81caf0c507fc22085a74f92187f (patch)
tree236ff810cbfc4dc264aa5943ff3dc2961130ed07 /docs/LangRef.html
parent543a02704e4d9ba9d0dd812658afc129048d37ec (diff)
downloadexternal_llvm-e67a951720caa81caf0c507fc22085a74f92187f.zip
external_llvm-e67a951720caa81caf0c507fc22085a74f92187f.tar.gz
external_llvm-e67a951720caa81caf0c507fc22085a74f92187f.tar.bz2
add a note about variable length array
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22278 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/LangRef.html')
-rw-r--r--docs/LangRef.html16
1 files changed, 16 insertions, 0 deletions
diff --git a/docs/LangRef.html b/docs/LangRef.html
index 3fac48d..73e7e2d 100644
--- a/docs/LangRef.html
+++ b/docs/LangRef.html
@@ -717,6 +717,14 @@ be any type with a size.</p>
</td>
</tr>
</table>
+
+<p>Note that 'variable sized arrays' can be implemented in LLVM With a zero
+length array. Normally accesses past the end of an array are undefined in
+LLVM (e.g. it is illegal to access the 5th element of a 3 element array).
+As a special case, however, zero length arrays are recognized to be variable
+length. This allows implementation of 'pascal style arrays' with the LLVM
+type "{ int, [0 x float]}", for example.</p>
+
</div>
<!-- _______________________________________________________________________ -->
@@ -1989,7 +1997,15 @@ the LLVM code for the given testcase is equivalent to:</p>
ret int* %t5
}
</pre>
+
+<p>Note that it is undefined to access an array out of bounds: array and
+pointer indexes must always be within the defined bounds of the array type.
+The one exception for this rules is zero length arrays. These arrays are
+defined to be accessible as variable length arrays, which requires access
+beyond the zero'th element.</p>
+
<h5>Example:</h5>
+
<pre>
<i>; yields [12 x ubyte]*:aptr</i>
%aptr = getelementptr {int, [12 x ubyte]}* %sptr, long 0, uint 1