This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Suggested FAQ entry
- To: Doug Semler <doug at seaspace dot com>
- Subject: Re: Suggested FAQ entry
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 11 Apr 1999 23:28:22 -0300
- Cc: "Martin v. Loewis" <martin at mira dot isdn dot cs dot tu-berlin dot de>, Gabriel dot Dos-Reis at cmla dot ens-cachan dot fr, egcs at egcs dot cygnus dot com, egcs-patches at egcs dot cygnus dot com
- References: <199904120035.RAA28378@vortex.seaspace.com>
On Apr 11, 1999, Doug Semler <doug@seaspace.com> wrote:
> + <p>The C++ language specifies that all virtual methods that are declared must
> + be defined. The linker error message is telling you that at least one
> + of the virtual methods declared has not been defined, as the constructors,
> + destructor, and virtual table was never emitted by egcs for the class.
> +
> + <p>The solution is to ensure all virtual methods are defined.
I'd rather rephrase it as attached. Ok to install?
--
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Brasil
{oliva,Alexandre.Oliva}@dcc.unicamp.br aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
*** E-mail about software projects will be forwarded to mailing lists
Index: faq.html
===================================================================
RCS file: /egcs/carton/cvsfiles/wwwdocs/htdocs/faq.html,v
retrieving revision 1.118
diff -u -r1.118 faq.html
--- faq.html 1999/03/29 12:51:24 1.118
+++ faq.html 1999/04/12 02:32:31
@@ -98,6 +98,7 @@
(<tt>-fsquangle</tt>)</a>
<li><a href="#gperf">When building from CVS sources, I see 'gperf: invalid option -- F',
even with the most current version of gperf.</a>
+ <li><a href="#vtables">When building C++, the linker says my constructors, destructors or virtual tables are undefined, but I defined them</a>
</ol>
</ol>
@@ -1166,6 +1167,27 @@
<hr>
+<h2><a name="vtables">When building C++, the linker says my constructors, destructors or virtual tables are undefined, but I defined them</a></h2>
+
+<p>The C++ Standard specifies that all virtual methods of a class that
+are not pure-virtual must be defined, but does not require any
+diagnostic for violations of this rule [class.virtual]/8. Based on
+this assumption, egcs will only emit the implicitly defined
+constructors, the assignment operator, the destructor and the virtual
+table of a class in the translation unit that defines its first such
+non-inline method.
+
+<p>Therefore, if you fail to define this particular method, the linker
+may complain about the lack of definitions for apparently unrelated
+symbols. Unfortunately, in order to improve this error message, it
+might be necessary to change the linker, and this can't always be
+done.
+
+<p>The solution is to ensure that all virtual methods that are not
+pure are defined. Note that a destructor must be defined even if it
+is declared pure-virtual [class.dtor]/7.
+
+<hr>
<p><a href="index.html">Return to the EGCS home page</a>
<p><i>Last modified: March 29, 1999</i>