www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9916] New: int*[] implicitly converts to int*

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

           Summary: int*[] implicitly converts to int*
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: phyphor0 gmail.com



Found on 2.062 on Windows, haven't tested other platforms, but it would
presumably be the same. Working version is 2.057. I'm not sure if this is a
compiler issue or something in the library instead

int x = 1, y = 2, z = 3;
int *[] a = [&x,&y,&z];
int *b = a;
int **c = a.ptr;

The previous bundle I have reports a no implicit conversion error on the b = a
assignment.

The result of this is (b == c) in raw pointer values and (*b == *c == &x), and
isImplicitlyConvertible!(int*[], int*) is evaluating to true.

Additional info:
- int*[] can convert to int*, but int[] can't convert to int, so it requires a
pointer somewhere
- if I change a from int*[] to int*[3], I get the error I would expect (no
implicit conversion)
- it does work for more than one level of pointers, but the type must match (ie
int***[] -> int***)

This is causing weirdness in the container templates because pointer usage
evaluates to multiple possible templates with isImplicitlyConvertible being
broken and is probably the cause of issue 9518

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 10 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9916


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID



In D's specification, implicit conversion from T[] to T is not allowed.

The code had accidentally changed to be accepted in 2.061, but the regression
was already fixed in 2.062 (Bug 9259 is directly related to the issue).

Therefore, the OP code is invalid and should not work.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 10 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9916




Yes, but the problem is it is compiling without error on 2.062 and that breaks
stuff

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 11 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9916


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
          Component|Phobos                      |DMD
         Resolution|INVALID                     |DUPLICATE




 Yes, but the problem is it is compiling without error on 2.062 and that breaks
 stuff
Oh... I completely had mistaken. Sorry confusion by my wrong comment. Yes, this is actually a regression. It had occurred from 2.061, and still exists in 2.062. Fortunately, this regression had been found in the 2.063 devel, and already fixed in bug 9539. You would get the fix in 2.063 release. Thanks! *** This issue has been marked as a duplicate of issue 9539 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 11 2013