[LLVMbugs] [Bug 20296] New: incorrect has internal linkage but is not defined [-Wundefined-internal] reported when a private class is used in a template

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jul 14 09:49:15 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20296

            Bug ID: 20296
           Summary: incorrect has internal linkage but is not defined
                    [-Wundefined-internal] reported when a private class
                    is used in a template
           Product: clang
           Version: 3.4
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: georgid at outlook.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12762
  --> http://llvm.org/bugs/attachment.cgi?id=12762&action=edit
source files used in the description

When trying to compile the following program:

cat tmp.cpp
template <template<typename A> class T>
class E {
public:
   typedef T<E> EType;
};


class Foo {
public:
   template<typename A>
   struct Nested { };

private:
   typedef Foo Type;
   typedef E<Nested>::EType EType;

public:
   typedef void (*MethodType)(EType& n);
public:
   static void adaptMethod(EType& n);

public:
   Foo()
      : _method(&Type::adaptMethod) { }

private:
   MethodType _method;
};


I get:

 clang++ -v -c -std=c++11 tmp.cpp
clang version 3.4 (http://llvm.org/git/clang
48eff6c3512fd6c768072b05ab4c287c7719072b) (http://llvm.org/git/llvm
8240ef04108620fef51219e9495a6e71e95ccd75)
Target: x86_64-unknown-linux-gnu
Thread model: posix
 "/dbc/sof2-dbc201/gdimitrov/sysroot/bin/clang" -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
tmp.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version
2.20.51.0.2 -v -coverage-file
/dbc/sof2-dbc201/gdimitrov/git-src/cayman/vapicpp_cfg/vapicpp/src/tmp.o
-resource-dir /dbc/sof2-dbc201/gdimitrov/sysroot/bin/../lib/clang/3.4
-internal-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7
-internal-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/x86_64-redhat-linux
-internal-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/backward
-internal-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/x86_64-redhat-linux/c++/4.4.7
-internal-isystem /usr/local/include -internal-isystem
/dbc/sof2-dbc201/gdimitrov/sysroot/bin/../lib/clang/3.4/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-std=c++11 -fdeprecated-macro -fdebug-compilation-dir
/dbc/sof2-dbc201/gdimitrov/git-src/cayman/vapicpp_cfg/vapicpp/src -ferror-limit
19 -fmessage-length 318 -mstackrealign -fobjc-runtime=gcc
-fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops
-o tmp.o -x c++ tmp.cpp
clang -cc1 version 3.4 based upon LLVM 3.4svn default target
x86_64-unknown-linux-gnu

tmp.cpp:20:16: warning: function 'Foo::adaptMethod' has internal linkage but is
not defined [-Wundefined-internal]
   static void adaptMethod(EType& n);
               ^
tmp.cpp:24:24: note: used here
      : _method(&Type::adaptMethod) { }
                       ^
1 warning generated.


The same code compiles fine with clang 3.2 and gcc 4.4, 4.8

If I change the code to this:
% cat tmp2.cpp
template <template<typename A> class T>
class E {
public:
   typedef T<E> EType;
};


template<typename A>
struct Nested { };   // Moved the class outside of Foo

class Foo {
public:
private:
   typedef Foo Type;
   typedef E<Nested>::EType EType;

public:
   typedef void (*MethodType)(EType& n);
public:
   static void adaptMethod(EType& n);

public:
   Foo()
      : _method(&Type::adaptMethod) { }

private:
   MethodType _method;
};

Or I change it to this:

cat tmp3.cpp
template <template<typename A> class T>
class E {
public:
   typedef T<int> EType; // use "int" instead of "E"
};


class Foo {
public:
   template<typename A>
   struct Nested { };

private:
   typedef Foo Type;
   typedef E<Nested>::EType EType;

public:
   typedef void (*MethodType)(EType& n);
public:
   static void adaptMethod(EType& n);

public:
   Foo()
      : _method(&Type::adaptMethod) { }

private:
   MethodType _method;
};

There is no warning issued.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140714/a5926b3e/attachment.html>


More information about the llvm-bugs mailing list