Why won't & x + 1 cause a seg error?

It uses this stream&x + 1 to determine the size of some random structure x. I wonder why this is a legal decision? Will this ever cause a segmentation error?

My understanding, as long as it &x + 1remains in the memory available for the current thread, it will be fine, but if in &x + 1some way it tries to access a part of the memory outside its allowable range, it will cause seg of fault, is that right?

+3
source share
2 answers

Third, the C standard explicitly allows pointers to point one after the end of an array.

... , ...

@alk, 1.

, , .

( 6.5.6.8 6.5.6.7 C99 )

+6

-, C , , . .

-, &x + 1, - .

, .

+5

All Articles