Summary: Function pointers need to be stricter
--- Comment #0 from yebblies <yebbl...@gmail.com> 2010-02-12 05:34:08 PST ---
Currently functions pointers can be implicitly converted despite having
different calling conventions. If at all possible, function pointers should
require a cast to change calling convention.
In a related problem, it is possible to implicitly convert function pointers
with different argument lists.
The following code compiles but segfaults (Access Violation) on dmd 2.040 /
void foo(real f)
writeln("bar ", f);
void function(ubyte) ptr1 = &foo;
extern(C) void function(long, long) ptr2 = ptr1;
ptr1([0xFF, 0xFF, 0xFF, 0xFF]);
Function pointers cannot, however, be cast to a pointer with a different return
To solve this problem: Disable all implicit conversions between function
pointers, requiring function parameters, return type, and calling convention to
match for assignment copying. This prevents accidental conversions and allows
template code to be aware of the correct calling convention.
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------