int dostuff(void) { static int somevalue = 12345; return somevalue; }
还是可以让多个线程调用这个函数,一次调用在执行开始之前返回任何垃圾都是& somevalue?
A local object of POD type (3.9) with static storage duration initialized with constant-expressions is initialized before its block is first entered.
这意味着函数级静态对象必须在第一次输入函数时初始化,而不一定是整个进程初始化时.此时,多个线程可能正在运行.