Type safety could prevent nuclear war
Daniel Murphy via Digitalmars-d
digitalmars-d at puremagic.com
Fri Feb 5 02:49:50 PST 2016
On 5/02/2016 11:03 AM, tsbockman wrote:
>
> The compiler cannot (in the general case) verify that `extern(C)`
> declarations are *correct*. What it could do, though, is verify that
> they are *consistent*.
>
> If the same `extern(C)` symbol is declared multiple places in the D
> source code for a program, the compiler should issue at least a warning
> if the D signatures don't agree with each other.
Currently D allows overloading extern(C) declarations, see
https://issues.dlang.org/show_bug.cgi?id=15217
Checking for invalid overloads with non-D linkage is covered here:
https://issues.dlang.org/show_bug.cgi?id=2789
But neither of these cover overloads that aren't simultaneously visible.
15217 shows us that this lack of checking, when combined with D's
abundant binary-compatible-but-distinct types, is somewhat useful.
Apart from some scary ABI hacks there is nothing really stopping us from
enforcing that all non-D function in all modules included in a single
compilation have distinct symbol names or (at least binary-compatible)
matching D parameters.
More information about the Digitalmars-d
mailing list