www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6940] New: immutable(int*)* and int** do not combine

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6940

           Summary: immutable(int*)* and int** do not combine
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: timon.gehr gmx.ch



immutable(int*)* and int** do not combine even though const(int*)* would be a
common type:

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

static assert(is(typeof(x) : const(int*)*)); // ok
static assert(is(typeof(y) : const(int*)*)); // ok
static assert(is(typeof(1?x:y)));            // fail


Compare to dynamic arrays:

immutable(int[])[]  a;
int[][]             b;

static assert(is(typeof(a) : const(int[])[])); // ok
static assert(is(typeof(b) : const(int[])[])); // ok
static assert(is(typeof(1?a:b)));              // ok

(why on earth do the two cases use different logic?)

Therefore the following could be used as a workaround:

static assert(is(typeof((1?x[0..1]:y[0..1]).ptr)));

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 12 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6940




 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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 16 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6940





 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: -------
Nov 17 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6940


timon.gehr gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|immutable(int*)* and int**  |immutable(int*)*/immutable(
                   |do not combine              |int)** and int** do not
                   |                            |combine



immutable(int)** and int** should also combine to const(int*)*

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 18 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6940


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch, rejects-valid



https://github.com/D-Programming-Language/dmd/pull/571

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 19 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6940


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



13:03:08 PST ---
https://github.com/D-Programming-Language/dmd/commit/06fe1ce97ef56cb86821114024c55f8d5fe0073c

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