I have seen that in the C++ abstract machines (if the are different), the mere act of forming a point to an invalid point in memory is undefined behavior.
For example
int* arr = new int[10];
int* last = arr + 9; // last element
int* end = arr + 10; // past last element, still ok according to the rules
int* another = arr + 11; // invalid, UB, supposedly, the rest of the program can be invalid
Now suppose, this other code
int* arr; // arr can be invalid already here, UB?
int* another = arr; // forming a pointer to possibly invalid memory, UB?
How is assigning an uninitialized pointer different from forming an invalid pointer by an operation? is it as bad?
int *arr;by itself is legal,int *another = arr;I think stops being UB in C++26?std::vector<int>in cases like this.std::vector<int> values;and then first and last will bevalues.begin()andvalues.end(). So be very very clear if you want a "C" or a "C++" answer ;)