$3.6.2/2- "Variables with static
storage duration (3.7.1) or thread
storage duration (3.7.2) shall be
zero-initialized (8.5) before any
other initialization takes place."
这就解释了为什么你会得到0的值
$3.6.2/4- "It is
implementation-defined whether the
dynamic initialization of a non-local
variable with static storage duration
is done before the first statement of
main. If the initialization is
deferred to some point in time after
the first statement of main, it shall
occur before the first use of any
function or variable defined in the
same translation unit as the variable
to be initialized."
因此,当您试图访问一个具有静态存储持续时间的变量时,您试图做的事情会导致未定义的行为,该变量尚未初始化,因为该转换单元中尚未使用任何代码。