#include <iostream>
using namespace std;
const int BUFSIZE = 1 << 20;
char padded_buffer[64 + BUFSIZE + 64];
char* buffer = padded_buffer + 64;
int main()
{
buffer[-1] = '?';
// is that always equivalent to padded_buffer[63] = '?' ?
cout << padded_buffer[63] << "\n";
return 0;
}
I have a piece of code like above. Basically, I need to "fence" the two side of my array for some reasons.
But I wonder if the syntax above is safe? I know that negative indexing is generally undefined behavior, but what about this case?