This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Bad error messages from missing =0 on virtual function decl
- To: Gabriel Dos Reis <gdr at codesourcery dot com>
- Subject: Re: Bad error messages from missing =0 on virtual function decl
- From: Carl Feynman <carlf at init dot com>
- Date: Thu, 24 Aug 2000 19:30:43 -0400
- CC: gcc-bugs at gcc dot gnu dot org
- Organization: Ab Initio Software Corporation
- References: <39A594F9.BB31032C@init.com> <flk8d6uxeh.fsf@riz.cmla.ens-cachan.fr>
Gabriel Dos Reis wrote:
> ...
>
> What type of logic do you want the compiler to use in order to deduce that,
> actually, you meant a pure virtual function when you declared a
> non-pure virtual function? The best it can do is to report the use of
> an undefined function.
>
That would be fine. Perhaps it could say "Function declared but not defined:
parent::foo()"? That would indicate to the user that the problem is in the
declaration of that function, and I'm sure that with a bit of staring I would
notice the missing =0.
Instead it says
In function `child type_info function':
undefined reference to `parent type_info function'
undefined reference to `parent type_info node'
In function `parent::parent(void)':
undefined reference to `parent virtual table'
This message is insufficient for three reasons.
(1) nowhere does it indicate which class is incorrect. Instead blame is heaped
equally on parent and child for an error in only one. ("The children shall
suffer for the sins of the fathers; Yea, unto the seventh generation.")
(2) the bad function is nowhere named.
(3) It claims that there are functions called `child type_info function', and
variables called `parent type_info function' and `parent type_info node'. I
assume these are some kind of internal compiler data structures. They're
certainly not functions or variables in my program.
It took three different approaches before we figured out what the bug was, even
with a smart cookie like Sam Kendall helping me.
Thank you for your attention to this problem.
--Carl Feynman