Wolfgang Roemer wrote:

The main.o will perfectly link with the library although main.o needs a double variable named maximum and the lib only offers an int variable named maximum. Because the symbol name does in no way reflect the variable type, everything links fine but in fact the variable named "minimum" gets scrambled in this example because "maximum" is accessed as if it is a double variable thus overwriting 4 additional bytes (in this case the 4 bytes of the variable minimum). The assertion will show that.

I tested that on Windows with Visual C++ as well and there main.obj doesn't link because the variable type is part of the symbol name and everthing is fine.

I think it would be very very important for the binary interface to have that feature as well.

I actually disagree with this, I think attempting to make the link fail
here would be a mistake.

What is more interesting is a proposal to have the linker give warnings
if the debug descriptions of symbols do not match. That can even work
across languages.

Reply via email to