Rory Mcguire <rjmcgu...@gm_no_ail.com> wrote:
Are all string literals that have the same value initialized to the same address?void main() { string same() { return "This"; } assert("This" is same()); assert("This" is "This"); } Can this be relied upon?
No. The same string in different object files may be different instances, as may of course those in dynamically linked libraries. I would think the optimizer feels free to move string literals around as it sees fit, and the spec does not anywhere state that the compiler should merge string literals. -- Simen
