Issue 75799
Summary [AMDGPU] Compiling with -x hip causes a linker error with host only function pointer
Labels backend:AMDGPU
Assignees
Reporter CRobeck
    clang++ fptr.cc  works successfully

clang++ -x hip fptr.cc fails with the following linker error:

lld: error: undefined hidden symbol: PrintStr::print_1(char const*)
lld: error: undefined hidden symbol: PrintStr::print_2(char const*)
lld: error: undefined hidden symbol: PrintStr::print_3(char const*)
lld: error: undefined hidden symbol: PrintStr::print_4(char const*)

Expected output:

1 . AA
2 . BB
3 . CC
4 . DD

```
#include <cstdio>

class PrintStr
{
public:
  enum n_funcs_val { n_funcs=5 } ;
  typedef void (PrintStr::*pstr_f_t)( const char* ) ;
  static const pstr_f_t pstr_f[n_funcs] ;

  PrintStr() {}
  ~PrintStr() {}

  void run() ;
  void print_1( char const *str ) ;
  void print_2( char const *str ) ;
  void print_3( char const *str ) ;
  void print_4( char const *str ) ;
} ;


const PrintStr::pstr_f_t (PrintStr::pstr_f)[] = {
  &PrintStr::print_1,
  &PrintStr::print_2,
 &PrintStr::print_3,
  &PrintStr::print_4,
  0,
} ;



void PrintStr::run()
{
  print_1( "AA" ) ;
 print_2( "BB" ) ;
  print_3( "CC" ) ;
  print_4( "DD" ) ;
}

void PrintStr::print_1 ( char const *str )
{
  printf ( "1 . %s\n", str ) ;
}


void PrintStr::print_2 ( char const *str )
{
  printf ( "2 . %s\n", str ) ;
}


void PrintStr::print_3 ( char const *str )
{
  printf ( "3 . %s\n", str ) ;
}


void PrintStr::print_4 ( char const *str )
{
  printf ( "4 . %s\n", str ) ;
}



int main(int argc, char *argv[])
{
  PrintStr *pstr = new PrintStr ;

  pstr->run() ;
 delete (pstr) ;
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to