D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 14746 - [REG2.068a] Behavior change with struct destructor and alias this
Summary: [REG2.068a] Behavior change with struct destructor and alias this
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords: pull, wrong-code
Depends on:
Blocks:
 
Reported: 2015-06-29 06:06 UTC by briancschott
Modified: 2017-07-19 17:41 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 briancschott 2015-06-29 06:06:41 UTC
```
import std.stdio;

void main()
{
	Ownership o;
	destroy(o);
}

struct HasADestructor
{
	~this() {writeln("test");}
}

struct Ownership
{
	HasADestructor* pointer;
	alias pointer this;
}

```

With 2.067.1 this program runs with no output. With 2.068.0-b1 it outputs the string "test". With both compiler versions simply letting the struct go out of scope does not result in any output.
Comment 1 Kenji Hara 2015-06-30 04:11:07 UTC
Introduced in:
https://github.com/D-Programming-Language/druntime/pull/1181
Comment 3 github-bugzilla 2015-07-01 09:10:19 UTC
Commits pushed to stable at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/1a2290b1c36f8cdf66a9c4ce388b6a4b38ff9735
fix Issue 14746 - Behavior change with struct destructor and alias this

https://github.com/D-Programming-Language/druntime/commit/2f087248923ad77014259a52695f3abda076c206
Merge pull request #1312 from 9rnsr/fix14746

[REG2.068a] Issue 14746 - Behavior change with struct destructor and alias this
Comment 4 Martin Nowak 2015-07-01 09:28:57 UTC
Same issue applies to postblitRecurse (which is used in std.conv).
We also wanted to replace the recursive templates with the new compiler generated xdtor and xpostblit.

https://github.com/D-Programming-Language/druntime/pull/1313

I think a similar issue plagues all the hasElaborateX templates.
Comment 7 github-bugzilla 2017-07-19 17:41:49 UTC
Commits pushed to dmd-cxx at https://github.com/dlang/druntime

https://github.com/dlang/druntime/commit/1a2290b1c36f8cdf66a9c4ce388b6a4b38ff9735
fix Issue 14746 - Behavior change with struct destructor and alias this

https://github.com/dlang/druntime/commit/2f087248923ad77014259a52695f3abda076c206
Merge pull request #1312 from 9rnsr/fix14746

https://github.com/dlang/druntime/commit/c8518f5b62ae501ea740bc1b1996230c9927c70f
fix Issue 14746 for postblitRecurse as well

https://github.com/dlang/druntime/commit/e0f2ca65b719fcc94dbd484bb9a8a0fe219ef806
Merge pull request #1313 from MartinNowak/fix14746