// warning: address of stack memory associated with local variable 'x' returned [-Wreturn-stack-address] #include int* dangling_pointer() { int x = 42; return &x; // returns address of a local variable } int main() { int* p = dangling_pointer(); // Using *p here would be undefined behavior (void)p; return 0; }