<div dir="ltr"><br><div>Hi,</div><div><br></div><div>Please consider the following code:</div><div><br></div><div><div>#include<stdio.h></div><div><br></div><div>int main()</div><div>{</div><div>  void *sp1 = __builtin_alloca(0);</div>
<div>  void *sp2 = __builtin_alloca(0);</div><div><br></div><div>  printf("sp1 points at %p\n", sp1);</div><div>  printf("sp2 points at %p\n", sp2);</div><div><br></div><div>}</div></div><div><br></div>
<div>gcc version- gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1)</div><div>On compiling it with gcc the output is:</div><div><br></div><div><div>sp1 points at 0xbffbe9d8</div><div>sp2 points at 0xbffbe9d8</div></div><div>
<br></div><div><div>clang version- clang version 3.4 (trunk 186087)</div></div><div>On compiling it with clang the output is:</div><div><div>sp1 points at 0xbf87d30f</div><div>sp2 points at 0xbf87d30e</div></div><div><br>
</div><div>Please if someone could explain this one byte difference in clang?</div><div>Does clang actually allocate memory even when  __builtin_alloca(0)?</div><div><br></div><div>Would be really helpful if someone could throw some light on how stack allocation and alignment takes place in clang?</div>
<div><br></div><div>Thanks,</div><div>Rahul </div><div>A Clang developer (beginner)</div></div>