The problem is that your char *word2 = "shoe"; stored in the .rodata section:
$ readelf -p .rodata adum String dump of section '.rodata': [ 4] shoe [ 9] %s
(This would be easier to see if you saved shoe in one variable and foot in another variable.)
The compiler is allowed to store the string constant in read-only memory, since the standard does not allow changing string literals.
Your first case is an explicitly initialized array of characters; the standard allows you to change them, so they are not saved in a read-only section.
source share