As often happens, the question you ask does not really concern the scope, but most likely the life of the object. The lifetime of an array object b ends at the end of the if block, and any attempts to access it after that lead to undefined behavior.
In fact, speaking in pedantic language, it is even more about a than about b : as soon as the lifetime of b ends, the value of a becomes undefined. An attempt to "do something" that relies on an undefined pointer value results in undefined behavior.
source share