This is an expected result. You can verify this by looking at the underlying assembly. For example, if I build with:
g++ -S ptr.c
then you can see the following in the file output (ptr.s):
.file "ptr.c"
.def ___main; .scl 2; .type 32; .endef
.section .rdata,"dr"
LC0:
.ascii "Hello\0" ; Note - "Hello" only appears once in
; this data section!
LC1:
.ascii "=\0"
LC2:
.ascii "!=\0"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
[... some stuff deleted for brevity ...]
LCFI5:
call ___main
movl $LC0, -12(%ebp) ; This sets str1
movl $LC0, -8(%ebp) ; This sets str2
movl -12(%ebp), %eax
I've commented the two key bits -- only one appearance of 'Hello' is in the rdata section of the underlying code, and you can see str1 and str2 are set towards the end, both pointing to the same label: LC0
. This is beacuse 'Hello' is a string literal and, importantly, is constant.
As others have pointed out - this is perfectly legal under the standards.