https://issues.dlang.org/show_bug.cgi?id=17748
--- Comment #5 from Simen Kjaeraas <simen.kja...@gmail.com> --- But the code is in D - the compiler isn't being asked to check any code that isn't D code. There are basically three options here: 1) Mangle S.foo as '_foo', and have it behave like an extern(C) function taking an S as its first parameter. 2) Disallow the code, via a compilation error or at the very least a warning. 3) Ignore 'extern(C)' and generate code that behaves counter to the programmer's expectations. Note that none of these options require the compiler to check the correctness of any code that is not D code. Currently, as this bug report points out, the option chosen is 3). This is the worst option, as it leads to an error at link-time, which might be in a dynamic linker at some unspecified later point. Since the compiler already knows that it won't mangle the name correctly, implementing 2) should be little work, and provide great help to the poor programmer who's bitten by this bug. Since pragma(mangle) works on struct methods, implementing 1) should also not be an insurmountable problem, but since C does not have methods, the calling convention is basically unspecified, and something will need to be done in that case. Not sure how much work this would be. The current solution is basically the worst possible, and for no good reason. The only way it could be worse is if it mangled the name as requested and still used the D calling convention. --