<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - incorrect has internal linkage but is not defined [-Wundefined-internal] reported when a private class is used in a template"
   href="http://llvm.org/bugs/show_bug.cgi?id=20296">20296</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>incorrect has internal linkage but is not defined [-Wundefined-internal] reported when a private class is used in a template
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.4
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>georgid@outlook.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12762" name="attach_12762" title="source files used in the description">attachment 12762</a> <a href="attachment.cgi?id=12762&action=edit" title="source files used in the description">[details]</a></span>
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 (<a href="http://llvm.org/git/clang">http://llvm.org/git/clang</a>
48eff6c3512fd6c768072b05ab4c287c7719072b) (<a href="http://llvm.org/git/llvm">http://llvm.org/git/llvm</a>
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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>