Assembly output to figure out lvalues from rvalues, assignment to array vs pointer
godbolt.org·15h·
Flag this post

Consider

int main(){ char *nameptr = "ale"; char namearr[] = "lea"; double dval = 0.5; } 

This assembles to (https://godbolt.org/z/rW16sc6hz):

.LC0: .string "ale" main: pushq %rbp movq %rsp, %rbp movq $.LC0, -8(%rbp) movl $6382956, -20(%rbp) movsd .LC1(%rip), %xmm0 movsd %xmm0, -16(%rbp) movl $0, %eax popq %rbp ret .LC1: .long 0 .long 1071644672 

Given that "ale" and "lea" are lvalues, what explains the difference in treatment of how they are encoded? "lea" gets encoded as decimal 6382956, which when converted to hex becomes the ascii values of l, e and a. "ale" is placed in a se...

Similar Posts

Loading similar posts...