Thread overview
[Issue 17769] dmd accepts conversion from shared(int)* to int* when value comes from method
Aug 21, 2017
anonymous4
Oct 03, 2017
Lucia Cojocaru
Nov 02, 2017
Lucia Cojocaru
Dec 17, 2022
Iain Buclaw
August 21, 2017
https://issues.dlang.org/show_bug.cgi?id=17769

anonymous4 <dfj1esp02@sneakemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86_64                      |All
                 OS|Linux                       |All

--
October 03, 2017
https://issues.dlang.org/show_bug.cgi?id=17769

Lucia Cojocaru <lucia.mcojocaru@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lucia.mcojocaru@gmail.com
           Assignee|nobody@puremagic.com        |lucia.mcojocaru@gmail.com

--
November 02, 2017
https://issues.dlang.org/show_bug.cgi?id=17769

--- Comment #1 from Lucia Cojocaru <lucia.mcojocaru@gmail.com> ---
The reason for the bug is that there are different overloads in dcast.d for
implicitConvTo for CallExp (int* foo = s.method() falling here) and Expression
(where the other examples in this issue go).
https://github.com/dlang/dmd/blob/master/src/ddmd/dcast.d#L179

Expression: https://github.com/dlang/dmd/blob/master/src/ddmd/dcast.d#L194 CallExp: https://github.com/dlang/dmd/blob/master/src/ddmd/dcast.d#L809

For: int* foo = s.method();
Code goes into visit(CallExp) and calls visit(Expression) which defaults to
NOMATCH(false).
https://github.com/dlang/dmd/blob/master/src/ddmd/dcast.d#L817

On NOMATCH, the checks continue in visit(CallExp) and if nothing is found, it
dafaults to success (true).
https://github.com/dlang/dmd/blob/master/src/ddmd/dcast.d#L940


Everything else hits the default in visit(Expression) which is NOMATCH - hence
the rejecting.

Now I have a fix here disallowing pointer conversions from shared to nonshared https://github.com/somzzz/dmd/commit/6fdead01822071b464016f1c0313358f40494de2

But DIP29 allows this kind of conversions as long as the pointers are unique. https://wiki.dlang.org/DIP29

This results in my fix breaking the following compiler tests for DIP29: https://github.com/dlang/dmd/blob/master/test/runnable/implicit.d#L217

I'm not sure how to check if the pointer is unique. Also, are there any other subtleties related to DIP29 that these changes could be disregarding?

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=17769

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
December 13
https://issues.dlang.org/show_bug.cgi?id=17769

--- Comment #2 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19306

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--