关于局部变量内存分配以及static关键字的问题

#include
#include
#include
using namespace std;
void test2(int count) {
printf("%d count:%d\n", this_thread::get_id(), count);
int ef[count];
int d[5];
printf("%d %d %p %d\n",this_thread::get_id(), count, d, sizeof(d));
static int a[5];
printf("%d %d %p %d\n", this_thread::get_id(), count, a, sizeof(a));
int b[5];
printf("%d %d %p %d\n", this_thread::get_id(), count, b, sizeof(b));
sleep(5);
}
void test() {
int count = 1;
while(count+=100){
test2(count);
}

}
int main() {
printf("Hello world!\n");
thread t1(test);
thread t2(test);
t1.join();
t2.join();
return 0;
}
我的编译器里这份代码中a,b,d的地址始终不变,理论上来说不应该不变呀,这应该是编译器的优化吧?
还有,我就是觉得static变量其实是在编译器就分配内存并不作改动,想验证这个,结果发现不止static变量地址不会变化普通定长数组地址也不改动,那岂不是很尴尬么。。。。我觉得我的想法是对的,因为static变量在不同线程中也不同,另一方面,百度发现确实这样。。。。
我的电脑上运行结果如下:
Hello world!
-990759168 count:101
-990759168 101 0x7f9fc4f22de0 20
-990759168 101 0x604180 20
-990759168 101 0x7f9fc4f22e00 20
-999151872 count:101
-999151872 101 0x7f9fc4721de0 20
-999151872 101 0x604180 20
-999151872 101 0x7f9fc4721e00 20
-990759168 count:201
-990759168 201 0x7f9fc4f22de0 20
-990759168 201 0x604180 20
-990759168 201 0x7f9fc4f22e00 20
-999151872 count:201
-999151872 201 0x7f9fc4721de0 20
-999151872 201 0x604180 20
-999151872 201 0x7f9fc4721e00 20
-990759168 count:301
-990759168 301 0x7f9fc4f22de0 20
-990759168 301 0x604180 20
-990759168 301 0x7f9fc4f22e00 20
-999151872 count:301
-999151872 301 0x7f9fc4721de0 20
-999151872 301 0x604180 20
-999151872 301 0x7f9fc4721e00 20

相同的代码,相同的编译选项,在相同的编译器上编译,静态变量地址不变很正常。

我觉得你没明白我的意思,我的程序中每次循环都会先申请一个不一样大的数组,那么为什么申请完之后后面的地址始终保持一样呢,明明它前面的那个数组大小改变了呀。

而且只有a是静态变量,b和d并不是。