D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20714 - Struct with postblitting member does not call it's copy constructor
Summary: Struct with postblitting member does not call it's copy constructor
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
: 20940 (view as issue list)
Depends on:
Blocks:
 
Reported: 2020-03-31 16:22 UTC by Ate Eskola
Modified: 2020-11-11 10:49 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Ate Eskola 2020-03-31 16:22:02 UTC
Tested with DMD 2.091.0:
```
struct Blitter
{	int payload;
    this(this){}
}

struct Adder
{	Blitter blitter;
	this(int payload){this.blitter.payload = payload;}
	this(ref Adder rhs){this.blitter.payload = rhs.blitter.payload + 1;}
}

void main()
{	import std.stdio;
	Adder piece1 = 1;
	auto piece2 = piece1;
	
	version (Excepted) assert (piece2.blitter.payload == 2);
	else assert (piece2.blitter.payload == 1);
}
```
Comment 1 RazvanN 2020-06-17 03:59:09 UTC
*** Issue 20940 has been marked as a duplicate of this issue. ***
Comment 2 Dlang Bot 2020-11-11 04:08:17 UTC
@RazvanN7 created dlang/dmd pull request #11945 "Fix Issues 20714, 20965 - Postblit has priority over copy constructor" fixing this issue:

- Fix Issues 20714, 20965 - Postblit has priority over copy constructor

https://github.com/dlang/dmd/pull/11945
Comment 3 Dlang Bot 2020-11-11 04:56:34 UTC
dlang/dmd pull request #11945 "Fix Issues 20714, 20965 - Postblit has priority over copy constructor" was merged into master:

- 40d0661190ac132dbb5d61e3804dd22bbea26602 by RazvanN7:
  Fix Issues 20714, 20965 - Postblit has priority over copy constructor

https://github.com/dlang/dmd/pull/11945
Comment 4 Dlang Bot 2020-11-11 10:49:11 UTC
dlang/dmd pull request #11947 "Revert PR 11945 (Postblit has priority over copy constructor)" was merged into master:

- bc6976a4cc7abe799856689c077406a269dc0c51 by Geod24:
  Revert "Fix Issues 20714, 20965 - Postblit has priority over copy constructor"
  
  This reverts commit c35ace622492da4ca53c055c9af0fa0346aa178b.
  
  PR 11945 / this commit introduces a silent change of behavior,
  which leads to fields with postblit not having their postblit
  called anymore.
  A deprecation path was proposed, and would require the user to
  disable postblit when a copy constructor is present,
  or issue a deprecation message otherwise.
  Other options are likely available to avoid a silent behavior change.
  However, since the PR was merged within 4 minutes of being submitted,
  there were no time for such suggestions.
  Additionally, the PR was lacking both a spec PR and a changelog entry.

https://github.com/dlang/dmd/pull/11947