I haven't read the standard about this, but it is possible that the variable exists on the stack outside of the local scope. What is required is appropriate construction and destruction when program flow hits block boundaries.
That is, the compiler can do things that you don't/shouldn't know about from the language's/programmer's point of view.
From our POV, x only exists once program flow crosses its declaration inside the while loop.
And by "allocated" I just mean "the stack pointer is moved".
So the memory will only be allocated once on entry to the function, and deallcoated when the function exits. Also note that allocation is trivial because it doesn't have to actually allocate memory, it just consumes stack space which has already been allocated.
HOWEVER, a variable inside a loop body will be constructed and destructed every time the loop runs. For a type like int this doesn't mean anything because it's a built-it type and has no ctor/dtor... bur for a complex type like string where the ctor/dtor is nontrivial and may require additional allocation.... this could be very, very wasteful.