指向数组的先行元素的指针是 UB。这是什么时候第一次定义的?

Pointer to one-before-first element of array is UB. When was this first defined so?

从 C17 开始,递减指向数组第一个元素的指针是未定义的行为。 引用C17标准说法

C17 6.5.6/8

If both the pointer operand and the result point to elements of the same array object, or one past the last element of the array object, the evaluation shall not produce an overflow; otherwise, the behavior is undefined.

这是定义 this 的最早标准吗?这种操作在早期标准中是如何定义的?以前合法吗?

最早的C标准C89在3.3.6 Additive Operators中有相同的规则:

When an expression that has integral type is added to or subtracted from a pointer, the integral value is first multiplied by the size of the object pointed to. The result has the type of the pointer operand. If the pointer operand points to a member of an array object, and the array object is large enough, the result points to a member of the same array object, appropriately offset from the original member. Thus if P points to a member of an array object, the expression P+1 points to the next member of the array object. Unless both the pointer operand and the result point to a member of the same array object, or one past the last member of the array object, the behavior is undefined. Unless both the pointer operand and the result point to a member of the same array object, or the pointer operand points one past the last member of an array object and the result points to a member of the same array object, the behavior is undefined if the result is used as the operand of a unary * operator.

我不相信形成指向数组“-1”元素的指针在 C 语言中是明确定义的。当然,可能有特定的实现恰好有效,或者被记录在案所以。