D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7316 - the result of a strongly pure function should implicitly convert to and from shared
Summary: the result of a strongly pure function should implicitly convert to and from ...
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-18 17:13 UTC by timon.gehr
Modified: 2018-11-12 10:21 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description timon.gehr 2012-01-18 17:13:54 UTC
The following code should compile:

int[] foo()pure{return new shared(int)[1];}
shared(int)[] bar()pure{return new int[2];}
void main(){
    shared a = foo();
    int[] b = bar();
}
Comment 1 timon.gehr 2018-11-12 10:21:16 UTC
This enhancement was based on the assumption that conversions to immutable of strongly pure function results are safe (as DMD currently allows it in @safe code), but as John Colvin points out [1], this is not actually the case. The same counterexample works here, therefore I am closing this as invalid.

[1] https://forum.dlang.org/post/lysfmrljbcvvfsprotag@forum.dlang.org