https://issues.dlang.org/show_bug.cgi?id=9655
Steven Schveighoffer <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #11 from Steven Schveighoffer <[email protected]> --- (In reply to bearophile_hugs from comment #9) > Why? I think the C standard requires those functions to have different > addresses. I don't think this is true. (In reply to bearophile_hugs from comment #9) > (In reply to yebblies from comment #7) > > > No, you shouldn't rely on this ever. > > Why? I think the C standard requires those functions to have different > addresses. So I think that C code is correct. (And indeed as far as I know > GCC replaces equal function implementations with a jump, to keep addressed > distinct). >From the C standard: Two pointers compare equal if and only if both are null pointers, both are pointers to the same object (including a pointer to an object and a subobject at its beginning) or function, both are pointers to one past the last element of the same array object, or one is a pointer to one past the end of one array object and the other is a pointer to the start of a different array object that happens to immediately follow the first array object in the address space. So it appears, from the "if and only if", that bearophile is right. But D does not have to follow C rules. Even if we define an extern(C) function in D, it does not mean we have to follow those rules. I would say the issues that might occur because of this change are astronomically small. Consider that a piece of code that depends on distinct functions having distinct addresses may still work just fine even with ICF. However, it should be noted on the spec that we deviate from those requirements. It currently does not address this point from what I could find. --
