wrong reference in a virtual table

Alexandre Oliva oliva@dcc.unicamp.br
Tue Jun 23 16:33:00 GMT 1998


Igor Levko <hornet@reksoft.ru> writes:

> There is a trick here. There are two classes defined with the same name
> - X
> but the definitions are in different .cc files.

That doesn't make this valid; you're violating the One Definition
Rule.  The problem is that a single virtual table for class X is
generated.  You may fix your program by defining class X in unnamed
namespaces; this will ensure that the different definitions are not
mixed up.

namespace {
  class X { /* ... */ };
}

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil




More information about the Gcc-bugs mailing list