I am reading APUE, and when I came to longjmp
, the question came. Before optimization, both the auto variable and register variable store in memory, after optimization, they store in register, the book says. But when I use objdump -S a.out
, I found both of them became to immediate operand. So ?
Your book was just simplifying. Even before optimizing there is no guarantee that variables are realized in memory. The difference between auto
and register
is just that you are not allowed to take the address of a register
variable. The C compiler can do anything that behaves the same as the abstract machine.
That your compiler realizes these variables as immediats is an indication that the values that you have there are small and are compile time constants. So you probably could have declared them const
or even as enum
constants in the first place.