[LLVMdev] Idea for Google Summer Code : C Compiler for EFI Byte Code implement in LLVM

琬菁楊 ching1119.cs96 at g2.nctu.edu.tw
Thu Apr 1 13:27:44 PDT 2010


Hello, Chris



> 2010/3/20 Chris Lattner <clattner at apple.com>
>
>
>> On Mar 19, 2010, at 2:40 PM, Louis Gerbarg wrote:
>>
>>
>>> What do you mean by "variable sized pointers"?  What does:
>>>
>>> struct  S {void *X; };
>>>
>>> return for sizeof(struct S); ?
>>>
>>
>> It doesn't, at least not for Intel's EBC compiler. They error out on any
>> sizeof that include a pointer.  A piece of EBC code can run in either a 32
>> bit or 64 bit environment, and everything in the compiler either needs to
>> cope with it (by conditionally choosing the size of offsets into structs,
>> for instance) or give up on it and abort. That also means that you cannot
>> compile code that depends on knowing pointer sizes in the preprocessor, etc.
>>
>>
>> Ok, that makes sense.  It could be done by generalizing the notions of
>> variably modified types (which are VLAs in C99) to include pointers.
>>
>
I have read the sizeof and VLA in C99
I found a example:
EXAMPLE 3 In this example, the size of a variable-length array is computed
and returned from a function:
#include <stddef.h>
size_t fsize3(int n)
{
  char b[n+3]; // variable length array
  return sizeof b; // execution time sizeof
}
int main()
{
  size_t size;
  size = fsize3(10); // fsize3 returns 13
  return 0;
}
And I found some information with clang about VLA
(http://clang.llvm.org/cxx_compatibility.html#vla)
Does llvm/clang doesn't support sizeof is evaluated at run time??

thanks

ching

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100402/337df99f/attachment.html>


More information about the llvm-dev mailing list