The following C function:
int main(void) { char name[10] = "H"; } Produces the following (unoptimized) assembly in Compiler Explorer:
main: pushq %rbp movq %rsp, %rbp movq $72, -10(%rbp) movw $0, -2(%rbp) <--------- ?? movl $0, %eax popq %rbp ret What does the line above do? I would think we would want to null terminal the string by adding a $0 but I don't undertand why it's being added at -2. If helpful, here is a screenshot:

-2(%rbp)and-1(%rbp)are the last 2 bytes of the 10-byte array. The first 8 of which were written bymovq.movqand then pads the last two with zero from themovw $0. Is that correct?