[Issue 10368] `immutable pure` constructors must not be allowed for mutable construction

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jun 15 14:59:56 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10368



--- Comment #2 from Jonathan M Davis <jmdavisProg at gmx.com> 2013-06-15 14:59:55 PDT ---
Actually, I take that back. The constructor here _is_ strongly pure. The
problem is not strong vs weak. The problem is that the compiler must guarantee
that nothing outside of the function ends up in the constructed object (or the
return value if we were dealing with a function returning a new object rather
than a constructor). And in _most_ cases, strong purity is enough for that (and
weak purity is often enough if the constructor's body is examined
appropriately), but the example shows how it's possible for a strongly pure
function to inadvertently cast away immutability on something which it doens't
own thanks to the fact that normally having pure functions access statics or
globals which are immutable isn't a problem.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list