C++ template instantiation aliasing problem
Stephen D. Holland
sdh4@tam.cornell.edu
Mon Feb 4 18:12:00 GMT 2002
More information about the Binutils mailing list
Mon Feb 4 18:12:00 GMT 2002
- Previous message (by thread): [RFA:] ld section location mishap. Attention PE, HPPA, PPC64.
- Next message (by thread): C++ template instantiation aliasing problem
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
If a (seemingly local) structure is defined differently in two different C++ modules, LD will select one instantiation of a templated function and apply it both modules, even if the instantiations differ. The problem is in how multiply defined symbols are handled. Traditionally with C, an error message would be generated. But with C++, it is desirable to merge template instantiations to reduce overall code size, so the first instantiation found is selected and the others are discarded. The problem is that there is another instantiation that is (and should be!) different and distinct. To solve this, the linker should -- Issue a warning when multiply defined symbols do not map to identical code -- (possibly) maintain multiple distinct versions in the generated binary I am using binutils-2.10.91.0.2-3 (RH 7.2) I have attached a testcase (tmpl_alias.tar.gz, 739 bytes) that demonstrates this problem. 'make test' demonstrates the testcase. I should note that adding the 'static' keyword to the template definition in linkbug.h works around the problem. Nevertheless, given the subtlety of the problem and the difficulty of tracking it down, a warning message is warranted. Steve Holland sdh4 a t cornell d o t edu -------------- next part -------------- A non-text attachment was scrubbed... Name: tmpl_alias.tar.gz Type: application/x-compressed-tar Size: 739 bytes Desc: URL: <https://sourceware.org/pipermail/binutils/attachments/20020204/ebdf011a/attachment.bin>
- Previous message (by thread): [RFA:] ld section location mishap. Attention PE, HPPA, PPC64.
- Next message (by thread): C++ template instantiation aliasing problem
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list