g++
允许可变长度数组 (VLA)作为扩展。sizeof
VLA 上的operator的结果很有趣:
int main ()
{
char size = 20, a[10], b[size];
cout<<"sizeof(a) = "<<sizeof(a)<<endl; // sizeof(a) = 10, (can be used as template param)
cout<<"sizeof(b) = "<<sizeof(b)<<endl; // sizeof(b) = 20 !! (can't used be as template param)
}
如果是sizeof(b)
,g++ 是否不遵循sizeof
仅在编译时评估的标准?是否sizeof
超载?