weird compiler warning

J

Joe Van Dyk

I'm compiling some code on a IRIX compiler (MIPSpro Compilers: Version
7.4.2m) with all warnings turned on, and I'm getting some of these warnings:


cc-3649 CC: ERROR at end of source
all virtual functions for class "std::__Named_exception" inline: static
virtual table generated


cc-3649 CC: ERROR at end of source
all virtual functions for class "std::logic_error" inline: static virtual
table generated



Anyone have any idea what the heck it means and why it's a problem?

Thanks,
Joe
 
A

Alan Johnson

Joe said:
I'm compiling some code on a IRIX compiler (MIPSpro Compilers: Version
7.4.2m) with all warnings turned on, and I'm getting some of these warnings:


cc-3649 CC: ERROR at end of source
all virtual functions for class "std::__Named_exception" inline: static
virtual table generated


cc-3649 CC: ERROR at end of source
all virtual functions for class "std::logic_error" inline: static virtual
table generated



Anyone have any idea what the heck it means and why it's a problem?

Thanks,
Joe

Many compilers implement virtual functions as follows (note, this is
not required by the standard, but is just a common implementation):

For each class that has virtual functions, create a table (called
vtable or "virtual table") of pointers to all virtual functions. Add
to the class an additional member that is a pointer to this table.
When dispatching a function virtually, follow the pointer to find the
vtable, find the appropriate function pointer in the vtable, call the
function.

Now, this works well in practice, except for the detail that the
compiler must find some place to actually put this table. A common
heuristic is to put it in the compilation unit that contains the
definition of the class's first non-inline virtual function. Obviously
this doesn't work if there are no non-inline virtual functions, as in
your case.

Faced with this situation, some compilers will use other smart tricks,
and others will generate a separate copy of the vtable in every
compilation in which the class is used, which may possibly increase the
runtime size of your program considerably. My guess is that your
compiler chooses this latter route, and is warning you about it.

The obvious solution is to not have any classes in which all virtual
functions are inlined. Such a concept is rarely useful anyway. A call
to a virtual function can only be inlined if the static type is known,
in which case why did you make the function virtual?
 
B

Bo Persson

The obvious solution is to not have any classes in which all virtual
functions are inlined. Such a concept is rarely useful anyway. A
call
to a virtual function can only be inlined if the static type is
known,

It might be known in some contexts, but not in others. Sometimes you
use an object directly, sometimes through a pointer or reference.
in which case why did you make the function virtual?

He didn't.

It's part of the standard library. .-)


Bo Persson
 
J

Joe Van Dyk

It might be known in some contexts, but not in others. Sometimes you
use an object directly, sometimes through a pointer or reference.


He didn't.

It's part of the standard library. .-)

Yes, so this warning is frustrating me. I don't see a way to turn off
that particular warning either.

Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top