Postblit bug
monarch_dodra via Digitalmars-d
digitalmars-d at puremagic.com
Fri Oct 17 10:25:46 PDT 2014
On Friday, 17 October 2014 at 16:19:47 UTC, IgorStepanov wrote:
> It's just common words=)
> I meant that when postblit is called when new object is being
> creating and doesn't exists for user code.
> E.g.
> const S v1 = v2;
> Ok, v1 _will_ be const when it will be _created_.
> However postblit can think that object is mutable, because it
> called before the first accessing to the object from user code.
> Thus I ask about case when postblit may mutate a const object,
> which created before postblitted object and may been accessed
> from user code before this postblitting.
That's way too many words for a single sentence for me to
understand ;)
But maybe this answers your question?
import std.stdio;
struct S
{
int* p;
this(this)
{
++*p;
}
}
void main()
{
immutable i = 0;
auto s1 = immutable(S)(&i);
auto s2 = s1;
assert(*&i == 0);
}
More information about the Digitalmars-d
mailing list