www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7196] New: Unfair function address overload resolution

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

           Summary: Unfair function address overload resolution
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: timon.gehr gmx.ch



Tested with DMD 2.057

auto foo(int x){return x;}
auto foo(double x){return x;}

void main() {
    auto x = (&foo)(1);   // ok
    auto y = (&foo)(1.0); // fail
}

Error: cannot implicitly convert expression (1) of type double to int

The code should either compile, or both lines should fail.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 01 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7196


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch, rejects-valid
           Platform|Other                       |All



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

AddrExp that is yet not bounded into an variable should keep unresolved
overload information.
So the both lines should compile.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 02 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7196


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com



This is strange - issue 52 is marked as fixed, so why does it still EVER pick
the wrong instance?

Where does the spec address the meaning of &foo if there's more than one
function called foo in scope?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 02 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7196





 This is strange - issue 52 is marked as fixed, so why does it still EVER pick
 the wrong instance?
This problem is only when the caller of CallExp is AddrExp (== &foo). bug 51 is the problems on initializer and rhs of AssignExp.
 Where does the spec address the meaning of &foo if there's more than one
 function called foo in scope?
In this case, CallExp can pick the original overload of foo in static. Therefore compiler should translate from (&foo)(arguments...) to foo(arguments...). Finally, the overload should be resolved. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 02 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7196






 This is strange - issue 52 is marked as fixed, so why does it still EVER pick
 the wrong instance?
This problem is only when the caller of CallExp is AddrExp (== &foo). bug 51 is the problems on initializer and rhs of AssignExp.
 Where does the spec address the meaning of &foo if there's more than one
 function called foo in scope?
In this case, CallExp can pick the original overload of foo in static. Therefore compiler should translate from (&foo)(arguments...) to foo(arguments...). Finally, the overload should be resolved.
If the compiler rewrites (&foo)(arguments...) to foo(arguments...), is it now able to inline delegates that are called directly like for example {x++;}() ? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 02 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7196





 If the compiler rewrites (&foo)(arguments...) to foo(arguments...), is it now
 able to inline delegates that are called directly like for example {x++;}() ?
Sorry, I'm not sure the meaning of 'inline'. If you means 'optimizing', I don't know direct called delegate would be inlined or not... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 02 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7196


Walter Bright <bugzilla digitalmars.com> changed:

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



00:45:18 PST ---
https://github.com/D-Programming-Language/dmd/commit/092ae010d75417a5436fd6502a024af5d21a7922

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