[llvm-dev] Building aggregate types with dynamically sized elements

Christer Swahn via llvm-dev llvm-dev at lists.llvm.org
Fri Jul 14 03:19:04 PDT 2017

I would agree that such a capability is a questionable fit for C.

However as others point out I think it depends on the language in question.
In this case the language has runtime information about the array lengths
and enforces the bounds strictly. The language's semantics for these
aggregate, occasionally dynamically sized types I think are good; my
problem is how best to map it onto LLVMs type model.

My concern as I said is about portability and alignment, if I roll my own
type layout and offset computations. Any advice regarding this is much


2017-07-14 12:03 GMT+02:00 David Chisnall <David.Chisnall at cl.cam.ac.uk>:

> On 14 Jul 2017, at 10:55, Alexander Benikowski <sebal007 at googlemail.com>
> wrote:
> >
> >> Note: C does not support this.  GCC has an extension (variable length
> arrays in structs), but clang doesn’t support it and it’s a terrible idea.
> > It might be complex but it is not terrible. Depends on the language
> capabilities implementing it. Delphi for example allows exactly that and
> finalizes its records through RTTI which allows to automatically free up
> the memory.
> The Pascal type system, unlike C, does not erase array lengths in various
> places, so doing the same thin in Pascal would be far less problematic than
> C.  That doesn’t alter the fact that it’s a terrible idea for C, where it
> encourages to error-prone code.
> David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170714/2bfcbd76/attachment.html>

More information about the llvm-dev mailing list