This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/21280] New: #pragma interface, templates, and "inline function used but never defined"


This bug report may be related to bug 20584, but I've got standalone compilable
code that not only produces a warning, but also fails to link.

File t.h:

#pragma interface

template<class T>
struct C
{
  explicit C(const T& t) : a(t) { }
  virtual ~C() { }
  T a;
};


File f.cc:

#include "t.h"

struct A
{
  A() { }
  virtual ~A() { }
};

int main()
{
  A a;
  C<A> c(a);
}


> g++ -g -Wall f.cc
t.h:7: warning: inline function 'A::A(const A&)' used but never defined
/tmp/ccM01LV4.o(.gnu.linkonce.t._ZN1CI1AEC1ERKS0_+0x21): In function `C<A>::C(A
const&)':
/home/jmaurer/IS/isgbe/servers/kfi/f.cc:12: undefined reference to `A::A(A const&)'

It used to work with gcc 3.4.3.

At the very least, the warning message should have an instantiation backtrace so
that the user knows that the "used" comes from the instantiation of C<A>.

-- 
           Summary: #pragma interface, templates, and "inline function used
                    but never defined"
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jens dot maurer at gmx dot net
                CC: Jens dot Maurer at is-teledata dot com,gcc-bugs at gcc
                    dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]