gnu.linkonce too aggressive

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Thu Mar 9 16:04:00 GMT 2000


> Well, the compiler cannot diagnose it at all, it will be left to
> collect2 or the linker, but can the compiler provide the information
> that could be used to diagnose the violation, if collect2 happens to
> be courteous enough?

The standard precisely does not require to diagnose this error because
it is difficult for an implementation to do so. If the functions are
not inline, you *will* get a linker error (duplicate symbol). 

If the functions are inline, it is not an error if they occur in
multiple object files - inline functions usually appear in multiple
objects.

The standard requires that each occurence of the inline function uses
the same sequence of tokens, and the same types. So the compiler
*could* produce a checksum on the sequence of tokens, and on the
declaration of types, to determine whether all copies of an inline
function are identical. That is currently not implemented. It is also
very difficult to implement, so it is unlikely that it will get
implemented any time soon - except, of course, somebody (you?) steps
forward.

Regards,
Martin


More information about the Gcc-bugs mailing list