How does the program know the type information of each pointer?

A simple example is as follows:

int a = 1
int* p = &a
...
...
int c = *p
Only the address information is retained in the

pointer, so when the program sees * p on the last line, it can know that "take an int from this place", then there must be a record somewhere that "p points to an int", so where is the record going on?

Mar.21,2021

the information pointing to int is used for static checking by the compiler. It is not recorded in the compiled program that p points to an int

.

as shown in the figure, although the pointer types of my above two functions are not the same, the compilation result is the same
https://godbolt.org/
. You can compile C into assembly online on this website

.
Menu