public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14865] New: Instanciation problem of template class derived from virtual base class
@ 2004-04-06 13:41 Clement dot Menier at inrialpes dot fr
  2004-04-06 14:08 ` [Bug c++/14865] [3.3 Regression] " pinskia at gcc dot gnu dot org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: Clement dot Menier at inrialpes dot fr @ 2004-04-06 13:41 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1899 bytes --]

Here is the test example that causes the problem. I tried to reduce it to its
strict minimum:

test.cpp:

#include <string>

class A  {
  std::string mesg;
};

class B : public virtual A {};

template <class Type> class C : public B {};

int main() {
  C<int> j;
}

By compiling it with g++ 3.3.1 (Mandrake 9.2):
   g++ -O1 -o test test.cpp

Returns error:

/tmp/ccwnGZD1.o(.text+0x23): In function `main':
: undefined reference to `VTT for C<int>'
collect2: ld a retourné 1 code d'état d'exécution

  It seems that it has some problem instanciating the template class C<int>
automatically. Here are different tests that DO work (each test is independant):

   - replace "std::string mesg" by "int mesg"
   - manually instanciate template class by putting
        "template class C<int>;"
      just before the main declaration
   - Move the delaration of j outside of main (global definition)
   - Compile with no optimisation (-O0 for example)

To clarify things I tested this under:
   gcc 3.3.1 by Mandrake 9.2 : Failed
   gcc 3.3.2 by Fedora : Failed
   gcc 3.3.3 home compiled (with no options) : Failed

   gcc 3.2.2 by RedHat 9 : Work

I thus suspect that this problem appeared with gcc versions 3.3 . It may also be
that gcc 3.3 is more strict on the code but I have found no indication to suport
this.

Clement Menier.

-- 
           Summary: Instanciation problem of template class derived from
                    virtual base class
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Clement dot Menier at inrialpes dot fr
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-px-linux-gnu
GCC target triplet: i686-px-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14865


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

end of thread, other threads:[~2005-04-30 13:37 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-06 13:41 [Bug c++/14865] New: Instanciation problem of template class derived from virtual base class Clement dot Menier at inrialpes dot fr
2004-04-06 14:08 ` [Bug c++/14865] [3.3 Regression] " pinskia at gcc dot gnu dot org
2004-04-15 15:42 ` [Bug c++/14865] [3.3/3.4/3.5 Regression] No instantiation of VTT at -O1 reichelt at gcc dot gnu dot org
2004-05-03  5:03 ` [Bug c++/14865] [3.3/3.4/3.5 Regression] [no-unit-at-a-time] " pinskia at gcc dot gnu dot org
2004-06-04  2:47 ` pinskia at gcc dot gnu dot org
2004-06-06  3:37 ` giovannibajo at libero dot it
2004-06-15  9:24 ` [Bug c++/14865] [3.3/3.4 " reichelt at gcc dot gnu dot org
2004-06-15 13:44 ` pinskia at gcc dot gnu dot org
2004-06-15 20:56 ` [Bug c++/14865] [3.3/3.4/3.5 " pinskia at gcc dot gnu dot org
2004-06-24 21:17 ` pinskia at gcc dot gnu dot org
2004-06-25 21:39 ` mmitchel at gcc dot gnu dot org
2004-06-25 21:59 ` jh at suse dot cz
2004-06-25 22:02 ` cvs-commit at gcc dot gnu dot org
2004-06-26 10:58 ` cvs-commit at gcc dot gnu dot org
2004-06-26 19:17 ` [Bug c++/14865] [3.3 " pinskia at gcc dot gnu dot org
2004-07-29 18:09 ` [Bug c++/14865] [3.3 Regression] " pinskia at gcc dot gnu dot org
2004-09-28 13:32 ` gdr at gcc dot gnu dot org
2005-04-30 13:37 ` gdr at gcc dot gnu dot org

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