Postblit bug
Marco Leise via Digitalmars-d
digitalmars-d at puremagic.com
Fri Oct 17 23:53:13 PDT 2014
Am Fri, 17 Oct 2014 17:25:46 +0000
schrieb "monarch_dodra" <monarchdodra at gmail.com>:
> 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);
> }
Consider that when passing a variable you can always remove
top level const-ness because a copy is made. This holds for
returns, parameters, assignments, ...
Post-blit is no different. The issue as I see it, is that D
doesn't have strong support for this notion of head-mutable or
else it would work with this type during post-blit:
struct S
{
immutable(int)* p;
this(this)
{
++*p;
}
}
--
Marco
More information about the Digitalmars-d
mailing list