Summary: Function pointer assignments ignore constness
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Jonathan M Davis <> 2010-09-18 17:13:04 
PDT ---
Take this program:

struct S

    this(int[] function(const int[])func)
        _func = func;

    @property int[] function(const int[]) func()
        return func;

    int[] function(const int[]) _func;

int[] add1(int[] num)
    return num ~ 1;

void main()
    auto s = S(&add1);

It shouldn't compile, but it does. add1() does not take a const int[] and
therefore could theoretically modify its arguments (though it doesn't here),
violating the type of the function pointer. Using in and immutable instead of
const has the same problem. They compile when they shouldn't.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to