Search code examples
cpointerslanguage-lawyerterminology

"Pointer to an object" vs. "pointer to an object type"


While reading the C11 standard I'm confused with the meaning of terms "pointer to an object" and "pointer to an object type" and with the consistency of using these terms in the standard.

Per my understanding:

  • "pointer to an object" is the value of a pointer
  • "pointer to an object type" is the pointer itself

Is this understanding correct?

Now consider C11, 6.3.2.3p7 (emphases added):

A pointer to an object type may be converted to a pointer to a different object type. If the resulting pointer is not correctly aligned 68) for the referenced type, the behavior is undefined. Otherwise, when converted back again, the result shall compare equal to the original pointer. When a pointer to an object is converted to a pointer to a character type, the result points to the lowest addressed byte of the object.

Here we see that both terms "pointer to an object type" and "pointer to an object" are used with the same verb "converted". So, what exactly is converted: the value of a pointer or the pointer itself?

Another example: C11, 6.5.6p7 (emphasis added):

For the purposes of these operators, a pointer to an object that is not an element of an array behaves the same as a pointer to the first element of an array of length one with the type of the object as its element type.

Consider C11, 6.5.6p7 (emphasis added):

int* x[1];

What exactly the array x contains: "pointer to an object" or "pointer to an object type"?


UPD. While experimenting with pointer to not an object type it was found that ICC and MSVC lack generation of diagnostics for constraint violations: https://godbolt.org/z/77Y5snM4K.


Solution

  • "Pointer to an object type" speaks about the pointer type, as determined at compile-time. An object type is any type other than a function type (C11 6.2.5 Types /1), so they mean pointers to anything other than functions.

    "Pointer to such-and-such object" speaks about the runtime value of the pointer (which object it points to). "To an object" implies that the pointer is not dangling.