hfinkel / llvm-project-cxxjit

Clang with JIT extensions
https://github.com/hfinkel/llvm-project-cxxjit/wiki
229 stars 23 forks source link

Is this expected to work? Attempt at minimal reproducer #18

Open jjwilke opened 4 years ago

jjwilke commented 4 years ago

I know there are limitations currently. The code:

#include <string>
#include <iostream>

std::string name;

template <int x>
[[clang::jit]] void run(const char* str){
  name = std::string(str);
  std::cout << name << std::endl;
}

int main(int argc, char** argv)
{
  run<0>("hi there");
  return 0;
}

yields the following error:

include/c++/v1/string:2314:5: error: no
      matching member function for call to '__move_assign'
    __move_assign(__str, integral_constant<bool,
    ^~~~~~~~~~~~~
build/break.cc:8:8: note: in
      instantiation of member function 'std::__1::basic_string<char,
      std::__1::char_traits<char>, std::__1::allocator<char> >::operator=' requested here
  name = std::string(str);
       ^
build/break.cc:14:3: note: in
      instantiation of function template specialization 'run<0>' requested here
  run<0>("hi there");  
  ^
clang-jit/build/break.cc:14:3: note: in
      instantiation of function template specialization 'run<0>' requested here
include/c++/v1/string:1615:10: note: 
      candidate function not viable: no known conversion from 'integral_constant<[...],
      __alloc_traits::propagate_on_container_move_assignment::value aka true>' to
      'integral_constant<[...], (false) aka false>' for 2nd argument
    void __move_assign(basic_string& __str, false_type)
         ^
include/c++/v1/string:1618:10: note: 
      candidate function not viable: no known conversion from 'integral_constant<...>' to
      'integral_constant<...>' for 2nd argument
    void __move_assign(basic_string& __str, true_type)
         ^
LLVM ERROR: Clang JIT failed!