Postblit bug

monarch_dodra via Digitalmars-d digitalmars-d at puremagic.com
Sat Oct 18 01:28:40 PDT 2014


On Saturday, 18 October 2014 at 06:43:28 UTC, Marco Leise wrote:
> 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

D has it for primitives, such as pointers, slices...

> else it would work with this type during post-blit:
>
> struct S
> {
>      immutable(int)* p;
>      this(this)
>      {
>          ++*p;
>      }
> }

Unsure how that's relevant? This code looks wrong to me no matter 
how you look at it?


More information about the Digitalmars-d mailing list