“未定义的行为”并不意味着它必须在该行代码上崩溃,而是意味着您不能保证任何结果。例如:int arr[4] = {0, 1, 2, 3};int* p = arr + 5; // I guess this is allowed to crash, but that would be a rather // unusual implementation choice on most machines.*p; //may cause a crash, or it may read data out of some other data structureassert(arr < p); // this statement may not be true // (arr may be so close to the end of the address space that // adding 5 overflowed the address space and wrapped around)assert(p - arr == 5); //this statement may not be true //the compiler may have assigned p some other value我敢肯定,这里还有很多其他例子。