Something went wrong. Try again.
A Tour of C++ for experienced programmers, as if C++26 is the only version that ever existed.
Something went wrong. Try again.
123456789101112131415// warning: address of stack memory associated with local variable 'x' returned [-Wreturn-stack-address]#include <cstddef>
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;}