️️
Size: a a a
️️
AZ
️️
VS
VS
AZ
️️
G
AZ
️️
G
int* foo(void) {тут действительно lifetime внутри скопа а malloc?
int a = 17; // a has automatic storage duration
return &a;
} // lifetime of a ends
int main(void) {
int* p = foo(); // p points to an object past lifetime ("dangling pointer")
int n = *p; // undefined behavior
}
AZ
D
int* foo(void) {тут действительно lifetime внутри скопа а malloc?
int a = 17; // a has automatic storage duration
return &a;
} // lifetime of a ends
int main(void) {
int* p = foo(); // p points to an object past lifetime ("dangling pointer")
int n = *p; // undefined behavior
}
️️
TS
D
️️
D
D
️️