Type safety could prevent nuclear war
tsbockman via Digitalmars-d
digitalmars-d at puremagic.com
Thu Feb 4 15:29:10 PST 2016
On Thursday, 4 February 2016 at 23:24:21 UTC, Chris Wright wrote:
> C linkage does zero name mangling, which is the problem. C++
> introduced name mangling, so compiling with g++ would show the
> error rather quickly. C99 is pretty close to C++98, but there
> are enough differences that that isn't a reliable diagnostic.
> (Though if you're familiar with the differences, you could use
> it as a quick way to show potential problem areas.)
>
> I suppose a compiler could produce two symbol tables, one
> featuring mangled names and one with unmangled names. The
> linker would prefer matching mangled names and issue a warning
> if it only had an unmangled match with a mangled false match.
That explains why the linker doesn't catch it. I still don't see
much excuse for the compiler allowing it though, beyond a desire
to allow each module to be compiled independently.
More information about the Digitalmars-d
mailing list