<br clear="all">Hello all,<br>I found that the alignment for stack value has no limitation, but for global value, it has a limitation.<br><br>Here is an example:<br><br>#include <stdio.h><br>#include <stdlib.h><br>
<br>char x[4000] __attribute__((aligned(4096)));<br><br>int<br>main (int argc, char ** argv) {<br>  char y[4000] __attribute__((aligned(4096)));<br>  printf("x is %p\n", x);<br>  printf("y is %p\n", y);<br>
  <br>  return 0;<br>}<br><br>After compiled with clang, the result is:<br>x is 0x804b000<br>y is 0xbf9d8000<br><br>They are both aligned to be 4096 as we expected.<br><br>Then we change the example as the following:<br><br>
char x[4000] __attribute__((aligned(8192)));<br>
<br>
int<br>
main (int argc, char ** argv) {<br>
  char y[4000] __attribute__((aligned(8192)));<br>
  printf("x is %p\n", x);<br>
  printf("y is %p\n", y);<br>
  <br>
  return 0;<br>
}<br><br>The result is :<br>x is 0x804d000<br>y is 0xbffd2000<br><br>We can see that the stack value y is aligned to be 8192, but the global value x is not!<br><br>My target OS is 32-bit Linux. Anyone can explain this? or is this a bug of clang? <br>
<br><br><br><br>-- <br>     Best Regards,<br>                                                                 Baozeng Ding<br>                                                                 OSTG,NFS,ISCAS<br><br><br>