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]
Other format: [Raw text]

Re: undefined reference to `vtable for ...'


Nathan Sidwell <nathan@codesourcery.com> writes:

> Denys Duchier wrote:
>
>> /home/denys/Mozart/mozart-gcc3/mozart/platform/emulator/mozart.h:725: undefined reference to `vtable for WidthPropagator'
>
> you have not defined all the functions declared in WidthPropagator. May be
> WidthPropagator::getProfile. To save space, g++ only emits the vtable in the
> object file containing a 'key' function. If you don't define the key
> function, you won't get a vtable either. (there are some other cases).
> This is not a bug, as even if you had the vtable, it'd reference the
> undefined key function, and so get an error.

I should say that this is code which has been working for many years.
I am now porting it to gcc 3.2 and (after some adjustments) it
compiles fine (except for thousands of "will never be executed"
warnings) but not with debugging switched on.

I just discovered that the .hh file was missing a "#pragma
interface".  Adding it got me further.  Then I discovered that the
corresponding "#pragma implementation" had to be placed in the .cc
file that actually implements the interface (ahem :-).  The gcc
documentation says that it must be placed in a "main input file", so I
had it in one of the main files that included the .hh, but obviously
that was not good enough.

is this a gcc bug, a documentation bug, or a comprehension bug?

Cheers,

-- 
Dr. Denys Duchier			Denys.Duchier@ps.uni-sb.de
Forschungsbereich Programmiersysteme	(Programming Systems Lab)
Universitaet des Saarlandes, Geb. 45	http://www.ps.uni-sb.de/~duchier
Postfach 15 11 50			Phone: +49 681 302 5618
66041 Saarbruecken, Germany		Fax:   +49 681 302 5615


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