[llvm-commits] CVS: llvm/docs/LangRef.html

Chris Lattner lattner at cs.uiuc.edu
Fri Jun 24 10:23:09 PDT 2005



Changes in directory llvm/docs:

LangRef.html updated: 1.110 -> 1.111
---
Log message:

add a note about variable length array


---
Diffs of the changes:  (+17 -1)

 LangRef.html |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletion(-)


Index: llvm/docs/LangRef.html
diff -u llvm/docs/LangRef.html:1.110 llvm/docs/LangRef.html:1.111
--- llvm/docs/LangRef.html:1.110	Wed Jun 22 15:38:11 2005
+++ llvm/docs/LangRef.html	Fri Jun 24 12:22:57 2005
@@ -717,6 +717,14 @@
     </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 @@
     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
@@ -3261,7 +3277,7 @@
 
   <a href="mailto:sabre at nondot.org">Chris Lattner</a><br>
   <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a><br>
-  Last modified: $Date: 2005/06/22 20:38:11 $
+  Last modified: $Date: 2005/06/24 17:22:57 $
 </address>
 </body>
 </html>






More information about the llvm-commits mailing list