The code uses a compound literal to have an "inline" (anonymous) array.
Since the array is only used with sizeof
, no actual runtime array is constructed or initialized, this is all done at compile-time by the compiler simply inspecting the code and figuring out its type.
A quick godbolting gives us:
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-20], edi
mov QWORD PTR [rbp-32], rsi
mov DWORD PTR [rbp-4], 20 # Load 'y' with 20 (size of 5 ints)
mov eax, DWORD PTR [rbp-4]
cdqe
shr rax, 2 # Divide by four, giving 5.
mov DWORD PTR [rbp-8], eax
mov eax, DWORD PTR [rbp-8]
pop rbp
ret
By the way: you're being inconsistent in your use of parentheses; they're not needed with sizeof
unless the argument is a type name, so the second use could be just
x = y / sizeof 1;
These two are commonly combined, but that's not possible here since your array is anonymous, of course.