[Issue 6940] immutable(int*)* and int** do not combine

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 17 11:41:04 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6940



--- Comment #2 from timon.gehr at gmx.ch 2011-11-17 11:40:16 PST ---
(In reply to comment #1)
> > static assert(is(typeof(x) : const(int*)*)); // ok
> 
> > static assert(is(typeof(a) : const(int[])[])); // ok
> 
> I think these two lines should not compile.
> They are the part of bug 4251.
> 
> Then, Both two cases should not have common type, IMO.

No, they are not part of bug 4251. This bug report is valid.

This is bug 4251:

immutable(int)** x;
immutable(int)[][] y;

static assert(is(typeof(x): const(int)**));
static assert(is(typeof(y): const(int)[][]));

Consider this:

immutable(int)** x;
int y;
// we now make *x point to y, even though y is not immutable:
const(int)** p = x; // bug 4251
*p=&y; // since p == x, this assigns &y to *x

That only works because immutable converted to const _two references deep_.

None of that is going on here, consider this:

immutable(int*)* x
int y;
// we now try to do the same thing
const(int*)* p = x; // assume this works
*p = y; // error!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list