[Issue 7725] New: Implicit function pointer cast

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 18 05:56:28 PDT 2012


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

           Summary: Implicit function pointer cast
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2012-03-18 05:56:43 PDT ---
void foo1(void function(int) f) {}
void foo2(void function(in int) f) {}
void bar1(int) {}
void bar2(in int) {}
void main() {
    foo1(&bar1); // OK
    foo2(&bar2); // OK
    foo1(&bar2); // Err
    foo2(&bar1); // Err
}



DMD 2.059head gives:

test.d(8): Error: function test.foo1 (void function(int) f) is not callable
using argument types (void function(const(int)))
test.d(8): Error: cannot implicitly convert expression (& bar2) of type void
function(const(int)) to void function(int)
test.d(9): Error: function test.foo2 (void function(const(int)) f) is not
callable using argument types (void function(int))
test.d(9): Error: cannot implicitly convert expression (& bar1) of type void
function(int) to void function(const(int))


I think void function(in int) is a subset of void function(int). So I think
only one of the calls should to give an error, while the other seems better as
safe implicit cast.

-- 
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