[LLVMdev] Changing the value returned by sizeof

Peter Conn
Wed, 09 Apr 2014 09:31:59 -0000

Ah, sorry, I made a typo, I'd meant to write:

MyStruct *a = malloc(sizeof(MyStruct));



On 9 April 2014 10:28, waxiadao at gmail.com <waxiadao at gmail.com>
wrote:

> a is a pointer.The size of a pointer always equals the size of an
> int,doesn't it?
> 在 2014-4-9 下午4:32，"Peter Conn" <conn.peter at gmail.com>写道：
>
>> Hello,
>>
>> I'm replacing a struct with another struct of a different size. A
problem
>> arises when the following line occurs in the source code:
>>
>> MyStruct *a = malloc(sizeof(a));
>>
>> The 'sizeof(a)' is turned into a constant in the LLVM IR,
resulting in
>> the wrong amount of memory being allocated for the struct. Is there any
way
>> to find all the constants that have arisen from sizeof?
>>
>> Thanks, Peter
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20140409/a910bb13/attachment.html>