Skip to content

dejagnu test fails to compile with clang g++.old-deja/g++.pt/friend10.C #19469

@llvmbot

Description

@llvmbot
Bugzilla Link 19095
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@spavloff

Extended Description

template <class T>
void f(T);

template <class U>
class C
{ 
  template <class T>
  friend void f(T)
  {
     C<U> c;
     c.i = 3;
  }
  
  public :
    
     void g()
     {
       f(3.0);
     }
    int i;
};

int main ()
{
  f(7);
  C<double> c;
  c.g();
}

This Test Case compiles with g++. Fails with clang, linker error - unable to find definition of function f() with following error :

Opensource/llvm/build/bin/clang friend10.C

/tmp/friend10-f7127e.o: In function `main':
friend10.C:(.text+0x16): undefined reference to `void f<int>(int)'
/tmp/friend10-f7127e.o: In function `C<double>::g()':
friend10.C:(.text._ZN1CIdE1gEv[_ZN1CIdE1gEv]+0x1b): undefined reference to `void f<double>(double)'
clang-3.5: error: linker command failed with exit code 1 (use -v to see invocation)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions