public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "bredelin at ucla dot edu" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/51812] New: Virtual public inheritance leads to "undefined reference" in header files. Date: Tue, 10 Jan 2012 14:32:00 -0000 [thread overview] Message-ID: <bug-51812-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51812 Bug #: 51812 Summary: Virtual public inheritance leads to "undefined reference" in header files. Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: bredelin@ucla.edu Created attachment 26292 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26292 The c++ file that has linker errors. Hi, Using gcc 4.7 causes new linker errors that are not present in e.g. 4.5, 4.6, or clang. These linker errors make it impossible to use header files that do not fully define some classes entirely in the header file. The errors look like: % g++-4.7 all5.C /tmp/ccfEMWL0.o: In function `Object::print() const': all5.C:(.text._ZNK6Object5printEv[_ZNK6Object5printEv]+0x58): undefined reference to `demangle(std::string const&)' /tmp/ccfEMWL0.o: In function `alphabet::compare(Object const&) const': all5.C:(.text._ZNK8alphabet7compareERK6Object[_ZNK8alphabet7compareERK6Object]+0x81): undefined reference to `typeinfo for alphabet' all5.C:(.text._ZNK8alphabet7compareERK6Object[_ZNK8alphabet7compareERK6Object]+0xa5): undefined reference to `operator==(alphabet const&, alphabet const&)' /tmp/ccfEMWL0.o: In function `alphabet::~alphabet()': all5.C:(.text._ZN8alphabetD1Ev[_ZN8alphabetD1Ev]+0xe): undefined reference to `vtable for alphabet' all5.C:(.text._ZN8alphabetD1Ev[_ZN8alphabetD1Ev]+0x26): undefined reference to `vtable for alphabet' /tmp/ccfEMWL0.o: In function `Triplets::Triplets(Triplets const&)': all5.C:(.text._ZN8TripletsC1ERKS_[_ZN8TripletsC1ERKS_]+0x3d): undefined reference to `VTT for Triplets' all5.C:(.text._ZN8TripletsC1ERKS_[_ZN8TripletsC1ERKS_]+0x51): undefined reference to `vtable for Triplets' all5.C:(.text._ZN8TripletsC1ERKS_[_ZN8TripletsC1ERKS_]+0x69): undefined reference to `vtable for Triplets' /tmp/ccfEMWL0.o:(.rodata._ZTV18AminoAcidsWithStop[_ZTV18AminoAcidsWithStop]+0x48): undefined reference to `alphabet::print() const' /tmp/ccfEMWL0.o:(.rodata._ZTV18AminoAcidsWithStop[_ZTV18AminoAcidsWithStop]+0x60): undefined reference to `alphabet::setup_letter_classes()' /tmp/ccfEMWL0.o:(.rodata._ZTV18AminoAcidsWithStop[_ZTV18AminoAcidsWithStop]+0x70): undefined reference to `alphabet::get_frequencies_from_counts(std::valarray<double> const&, double) const' /tmp/ccfEMWL0.o:(.rodata._ZTC18AminoAcidsWithStop0_10AminoAcids[_ZTV18AminoAcidsWithStop]+0x48): undefined reference to `alphabet::print() const' /tmp/ccfEMWL0.o:(.rodata._ZTC18AminoAcidsWithStop0_10AminoAcids[_ZTV18AminoAcidsWithStop]+0x60): undefined reference to `alphabet::setup_letter_classes()' /tmp/ccfEMWL0.o:(.rodata._ZTC18AminoAcidsWithStop0_10AminoAcids[_ZTV18AminoAcidsWithStop]+0x70): undefined reference to `alphabet::get_frequencies_from_counts(std::valarray<double> const&, double) const' /tmp/ccfEMWL0.o:(.rodata._ZTC18AminoAcidsWithStop0_8alphabet[_ZTV18AminoAcidsWithStop]+0x30): undefined reference to `typeinfo for alphabet' /tmp/ccfEMWL0.o:(.rodata._ZTC18AminoAcidsWithStop0_8alphabet[_ZTV18AminoAcidsWithStop]+0x48): undefined reference to `alphabet::print() const' /tmp/ccfEMWL0.o:(.rodata._ZTC18AminoAcidsWithStop0_8alphabet[_ZTV18AminoAcidsWithStop]+0x60): undefined reference to `alphabet::setup_letter_classes()' /tmp/ccfEMWL0.o:(.rodata._ZTC18AminoAcidsWithStop0_8alphabet[_ZTV18AminoAcidsWithStop]+0x70): undefined reference to `alphabet::get_frequencies_from_counts(std::valarray<double> const&, double) const' /tmp/ccfEMWL0.o:(.rodata._ZTV10AminoAcids[_ZTV10AminoAcids]+0x48): undefined reference to `alphabet::print() const' /tmp/ccfEMWL0.o:(.rodata._ZTV10AminoAcids[_ZTV10AminoAcids]+0x60): undefined reference to `alphabet::setup_letter_classes()' /tmp/ccfEMWL0.o:(.rodata._ZTV10AminoAcids[_ZTV10AminoAcids]+0x70): undefined reference to `alphabet::get_frequencies_from_counts(std::valarray<double> const&, double) const' /tmp/ccfEMWL0.o:(.rodata._ZTC10AminoAcids0_8alphabet[_ZTV10AminoAcids]+0x30): undefined reference to `typeinfo for alphabet' /tmp/ccfEMWL0.o:(.rodata._ZTC10AminoAcids0_8alphabet[_ZTV10AminoAcids]+0x48): undefined reference to `alphabet::print() const' /tmp/ccfEMWL0.o:(.rodata._ZTC10AminoAcids0_8alphabet[_ZTV10AminoAcids]+0x60): undefined reference to `alphabet::setup_letter_classes()' /tmp/ccfEMWL0.o:(.rodata._ZTC10AminoAcids0_8alphabet[_ZTV10AminoAcids]+0x70): undefined reference to `alphabet::get_frequencies_from_counts(std::valarray<double> const&, double) const' /tmp/ccfEMWL0.o:(.rodata._ZTV3RNA[_ZTV3RNA]+0x48): undefined reference to `alphabet::print() const' /tmp/ccfEMWL0.o:(.rodata._ZTV3RNA[_ZTV3RNA]+0x60): undefined reference to `alphabet::setup_letter_classes()' /tmp/ccfEMWL0.o:(.rodata._ZTV3RNA[_ZTV3RNA]+0x70): undefined reference to `alphabet::get_frequencies_from_counts(std::valarray<double> const&, double) const' /tmp/ccfEMWL0.o:(.rodata._ZTC3RNA0_11Nucleotides[_ZTV3RNA]+0x48): undefined reference to `alphabet::print() const' /tmp/ccfEMWL0.o:(.rodata._ZTC3RNA0_11Nucleotides[_ZTV3RNA]+0x60): undefined reference to `alphabet::setup_letter_classes()' /tmp/ccfEMWL0.o:(.rodata._ZTC3RNA0_11Nucleotides[_ZTV3RNA]+0x70): undefined reference to `alphabet::get_frequencies_from_counts(std::valarray<double> const&, double) const' /tmp/ccfEMWL0.o:(.rodata._ZTC3RNA0_8alphabet[_ZTV3RNA]+0x30): undefined reference to `typeinfo for alphabet' /tmp/ccfEMWL0.o:(.rodata._ZTC3RNA0_8alphabet[_ZTV3RNA]+0x48): undefined reference to `alphabet::print() const' /tmp/ccfEMWL0.o:(.rodata._ZTC3RNA0_8alphabet[_ZTV3RNA]+0x60): undefined reference to `alphabet::setup_letter_classes()' /tmp/ccfEMWL0.o:(.rodata._ZTC3RNA0_8alphabet[_ZTV3RNA]+0x70): undefined reference to `alphabet::get_frequencies_from_counts(std::valarray<double> const&, double) const' /tmp/ccfEMWL0.o:(.rodata._ZTV3DNA[_ZTV3DNA]+0x48): undefined reference to `alphabet::print() const' /tmp/ccfEMWL0.o:(.rodata._ZTV3DNA[_ZTV3DNA]+0x60): undefined reference to `alphabet::setup_letter_classes()' /tmp/ccfEMWL0.o:(.rodata._ZTV3DNA[_ZTV3DNA]+0x70): undefined reference to `alphabet::get_frequencies_from_counts(std::valarray<double> const&, double) const' /tmp/ccfEMWL0.o:(.rodata._ZTC3DNA0_11Nucleotides[_ZTV3DNA]+0x48): undefined reference to `alphabet::print() const' /tmp/ccfEMWL0.o:(.rodata._ZTC3DNA0_11Nucleotides[_ZTV3DNA]+0x60): undefined reference to `alphabet::setup_letter_classes()' /tmp/ccfEMWL0.o:(.rodata._ZTC3DNA0_11Nucleotides[_ZTV3DNA]+0x70): undefined reference to `alphabet::get_frequencies_from_counts(std::valarray<double> const&, double) const' /tmp/ccfEMWL0.o:(.rodata._ZTC3DNA0_8alphabet[_ZTV3DNA]+0x30): undefined reference to `typeinfo for alphabet' /tmp/ccfEMWL0.o:(.rodata._ZTC3DNA0_8alphabet[_ZTV3DNA]+0x48): undefined reference to `alphabet::print() const' /tmp/ccfEMWL0.o:(.rodata._ZTC3DNA0_8alphabet[_ZTV3DNA]+0x60): undefined reference to `alphabet::setup_letter_classes()' /tmp/ccfEMWL0.o:(.rodata._ZTC3DNA0_8alphabet[_ZTV3DNA]+0x70): undefined reference to `alphabet::get_frequencies_from_counts(std::valarray<double> const&, double) const' /tmp/ccfEMWL0.o:(.rodata._ZTV11Nucleotides[_ZTV11Nucleotides]+0x48): undefined reference to `alphabet::print() const' /tmp/ccfEMWL0.o:(.rodata._ZTV11Nucleotides[_ZTV11Nucleotides]+0x60): undefined reference to `alphabet::setup_letter_classes()' /tmp/ccfEMWL0.o:(.rodata._ZTV11Nucleotides[_ZTV11Nucleotides]+0x70): undefined reference to `alphabet::get_frequencies_from_counts(std::valarray<double> const&, double) const' /tmp/ccfEMWL0.o:(.rodata._ZTC11Nucleotides0_8alphabet[_ZTV11Nucleotides]+0x30): undefined reference to `typeinfo for alphabet' /tmp/ccfEMWL0.o:(.rodata._ZTC11Nucleotides0_8alphabet[_ZTV11Nucleotides]+0x48): undefined reference to `alphabet::print() const' /tmp/ccfEMWL0.o:(.rodata._ZTC11Nucleotides0_8alphabet[_ZTV11Nucleotides]+0x60): undefined reference to `alphabet::setup_letter_classes()' /tmp/ccfEMWL0.o:(.rodata._ZTC11Nucleotides0_8alphabet[_ZTV11Nucleotides]+0x70): undefined reference to `alphabet::get_frequencies_from_counts(std::valarray<double> const&, double) const' /tmp/ccfEMWL0.o:(.rodata._ZTI10AminoAcids[_ZTI10AminoAcids]+0x10): undefined reference to `typeinfo for alphabet' /tmp/ccfEMWL0.o:(.rodata._ZTI11Nucleotides[_ZTI11Nucleotides]+0x10): undefined reference to `typeinfo for alphabet' collect2: error: ld returned 1 exit status All the errors go away if you change class alphabet to not have virtual public inheritance, by removing the word "virtual".
next reply other threads:[~2012-01-10 14:32 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-01-10 14:32 bredelin at ucla dot edu [this message] 2012-01-10 14:33 ` [Bug c++/51812] " bredelin at ucla dot edu 2012-01-10 15:09 ` bredelin at ucla dot edu 2012-01-22 20:35 ` [Bug c++/51812] [4.7 regression] " paolo.carlini at oracle dot com 2012-01-22 21:42 ` pinskia at gcc dot gnu.org 2012-01-22 22:10 ` [Bug c++/51812] [4.7 regression] Virtual public inheritance and thunks " pinskia at gcc dot gnu.org 2012-01-23 17:07 ` jason at gcc dot gnu.org 2012-01-23 18:14 ` jason at gcc dot gnu.org 2012-01-23 23:14 ` bredelin at ucla dot edu 2012-01-24 14:32 ` jason at gcc dot gnu.org 2012-01-24 14:54 ` jason at gcc dot gnu.org 2012-01-29 19:01 ` bredelin at ucla dot edu
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-51812-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).