Re:Puzzle Languages
by foldr on Wednesday October 04, 2023 @06:46AM
(#37763288)
This could happen any time you return a pointer to a variable with automatic storage and then later attempt to dereference the pointer and do something with the value. Of course, you shouldn't do that, but the C++ compiler won't stop you. 'Scope' can have various meanings, but merely understanding how lexical scoping of variables works is not sufficient to understand why you shouldn't do that.
[ Parent
| on HN ]
well, let me rephrase "scope" as "lifetime of objects"