st1
and st2
are pointers to read-only string literals. (Really you should use const char*
as the type but compilers are relaxed about this.)
On this particular occasion, the compiler has optimised the code so only one string literal is stored. This optimisation is permitted since the C standard states that any attempt to modify a read-only string is undefined behaviour. So the pointers have the same address. Hence st1 == st2
(which compares the pointer addresses not the contents) is true.
The C standard does not mandate this behaviour, so don't rely on it.