This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: wrong reference in a virtual table


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]