[Issue 24454] Disallow initialization of non-static reference type data members by non-immutable values or rvalues

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 29 15:24:20 UTC 2024


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

--- Comment #4 from Bolpat <qs.il.paperinik at gmail.com> ---
(In reply to Steven Schveighoffer from comment #1)
> case c2 seems fine to me. What is the problem with it? This seems akin to
> string interning.

Strings barely have identity, but class objects in general have identity. One
might expect every `S` default initialized instance has its own `immutable C`
object referenced by `c2`, but that’s not the case! Surprising programmers
simply isn’t a great idea and a workaround is easy.

--


More information about the Digitalmars-d-bugs mailing list