3 ms·
Interestingly, we get .LC0: .string "Lorem ipsum" [...] movl $.LC0, %esi movl $ptr2, %edi
by tonyg 9y ago
Interestingly, we get
.LC0:
.string "Lorem ipsum"
[...]
movl $.LC0, %esi
movl $ptr2, %edi
xorl %eax, %eax
jmp bogus
for the same experiment done with a const pointer to const data,
const char * const ptr2 = "Lorem ipsum";
(Incidentally, this kind of thing is why I prefer to write 'char const STAR const' rather than 'const char STAR const', and 'char const STAR' rather than 'const char STAR'; it systematically places the 'const's.)
(PS. HN really doesn't work well for trying to write either unicode or ascii star characters.)
- a_t48 9y agoHence the need to compile with -O2 rather than -O3, I would assume.
- smilekzs 9y agoHad parent been a StackOverflow post, this would be the undisputed correct answer.
- bsder 9y agochar const * const ptr2 = "Lorem ipsum"; Edit: Said exact same thing as parent but formatted differently. Sorry. :)