On 8/19/10, 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?
>

Well, since in Windows at least, string literals can be concatenated
to and whatnot, I very much doubt that there's any sharing involved.
You can always check with the is operator though. If it reports true,
then the two strings have the same instance. If it reports false, then
they don't.

Reply via email to