https://issues.dlang.org/show_bug.cgi?id=14459

--- Comment #3 from Dan Olson <go...@comcast.net> ---
(In reply to yebblies from comment #1)
> Why do you think string literals must be merged?  I would guess it's in
> 'implementation defined' territory, and identity equality should not be
> relied on.

Yes I agree in general it is implementation defined for any D compiler to merge
string literals.  In this case, one pointer is initialized to the the value of
another, so they do need to be equal.  The dmd front end code propagates const
char* literals into unique StringExps when used.  Now the backend must merge
StringExps with identical literals or else bad code can be generated.  In LDC
which uses dmd front end, it was worse because string literals were merged late
and even simpler code was wrong.  See
https://github.com/ldc-developers/ldc/issues/898 for details.

In the snippet, it leads to p0 == s0, as they should be, then a few lines
later, suddenly p0 != s0.

Anyway, it is in the backend el.c stable[16] where the cache is defined.  Also,
the code in the frond end that does the const propagation of string literals is
fromConstInitializer() in optimize.c

--

Reply via email to