g++: a bug or a feature ???

Nathan Sidwell nathan@acm.org
Wed Jul 17 01:28:00 GMT 2002


Yzhar Keysar wrote:
> when writing two fuctors ( or for simplicity : inline functions ) with
> the same prototype ( i.e. signature) but in different objects ,
> I get no warning in compile time nor in linkage time. and runtime uses
> only ONE copy of them.
As you realise, you are breaking the one definition rule [3.2].

> //main.cc
> #include <iostream>
> #include "test.hh"
> 
> inline void g() { cerr<<"Main.g()\n" ; }
you could make this static inline, if it only in one source file.
you could use namespaces (like the unnamed namespace)
namespace {
	inline void g ().....
}

void main () ...

of course it would be nice if the linker could check that two
merged symbols 'came from the same place' (but that's sometimes
not well defined).

nathan

-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
           The voices in my head told me to say this
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk



More information about the Gcc-help mailing list