There is no such magic rule in the C standard, that second int
object is to be set with 1
. In fact, the value is indeterminate, in which case the code invokes unconditional UB.
C11 § 6.3.2.1/2 Lvalues, arrays, and function designators
If the lvalue designates an object of automatic storage duration that
could have been declared with the register
storage class (never had
its address taken), and that object is uninitialized (not declared
with an initializer and no assignment to it has been performed prior
to use), the behavior is undefined.
But let's assume otherwise for a short moment. Here is just one example assembly, generated for x86-64 architecture on GCC 6.3, turned-off optimization, SysV ABI calling conventions:
mov DWORD PTR [rbp-4], -1
mov eax, DWORD PTR [rbp-8] ; ???
mov DWORD PTR [rbp-12], eax
mov eax, DWORD PTR [rbp-12]
mov DWORD PTR [rbp-16], eax
mov eax, DWORD PTR [rbp-16]
mov DWORD PTR [rbp-20], eax
mov eax, DWORD PTR [rbp-20]
mov DWORD PTR [rbp-24], eax
As far, as the compiler is concerned, there are neither no guarantees. The variable c
is located on current stack frame at RBP-8
offset. Its initial value is whatever was kept previously on stack.