[cfe-dev] Memory allocation in current function stack using __builtin_alloca
Rahul Jain
1989.rahuljain at gmail.com
Sat Jul 13 05:00:45 PDT 2013
Hi,
Please consider the following code:
#include<stdio.h>
int main()
{
void *sp1 = __builtin_alloca(0);
void *sp2 = __builtin_alloca(0);
printf("sp1 points at %p\n", sp1);
printf("sp2 points at %p\n", sp2);
}
gcc version- gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1)
On compiling it with gcc the output is:
sp1 points at 0xbffbe9d8
sp2 points at 0xbffbe9d8
clang version- clang version 3.4 (trunk 186087)
On compiling it with clang the output is:
sp1 points at 0xbf87d30f
sp2 points at 0xbf87d30e
Please if someone could explain this one byte difference in clang?
Does clang actually allocate memory even when __builtin_alloca(0)?
Would be really helpful if someone could throw some light on how stack
allocation and alignment takes place in clang?
Thanks,
Rahul
A Clang developer (beginner)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130713/21bb71b0/attachment.html>
More information about the cfe-dev
mailing list