public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51812] New: Virtual public inheritance leads to "undefined reference" in header files.
@ 2012-01-10 14:32 bredelin at ucla dot edu
  2012-01-10 14:33 ` [Bug c++/51812] " bredelin at ucla dot edu
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: bredelin at ucla dot edu @ 2012-01-10 14:32 UTC (permalink / raw)
  To: gcc-bugs

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".


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-01-29 18:31 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-10 14:32 [Bug c++/51812] New: Virtual public inheritance leads to "undefined reference" in header files bredelin at ucla dot edu
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

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).