D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10114 - Some implicit conversions to immutable and shared should be allowed
Summary: Some implicit conversions to immutable and shared should be allowed
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-17 23:41 UTC by Walter Bright
Modified: 2013-05-18 00:26 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 Walter Bright 2013-05-17 23:41:07 UTC
The following should work:
--------------------------
struct S {
    int a;
    immutable(int)* p;
}

struct T {
    int a;
    shared(int)* p;
}

void main() {
    auto s = S();
    immutable(S)*p = &s; // cannot implicitly convert expression
                         // (& s) of type S* to immutable(S)*

    shared(S)* q = &s; // cannot implicitly convert expression
                       // (& s) of type S* to shared(S)*

    auto t = T();
    shared(T)* r = &t; // cannot implicitly convert expression
                       // (& t) of type T* to shared(T)*
}
---------------------------

It should also work not only with pointers, but all reference types (such as dynamic arrays).
Comment 1 Walter Bright 2013-05-18 00:26:38 UTC
ack, what was I thinking