Description of bug
The following test fails:
TYPED_TEST(CPPINTEROP_TEST_MODE, FunctionReflection_FunctionPointerReferences) {
std::vector<Decl*> Decls;
std::string code = R"(
bool callme_ptr(bool (f)()) { return f(); }
bool callme_ref(bool (&f)()) { return f(); }
bool f() { return true; }
)";
GetAllTopLevelDecls(code, Decls);
auto f1 = Cpp::MakeFunctionCallable(Decls[0]);
EXPECT_EQ(f1.getKind(), Cpp::JitCall::Kind::kGenericCall);
auto f2 = Cpp::MakeFunctionCallable(Decls[2]);
EXPECT_EQ(f2.getKind(), Cpp::JitCall::Kind::kGenericCall); // fails
}
Note the pointer function works fine, i.e. bool callme_ptr(bool (f)()) { return f(); }. The reference version does not compile.
Code generated:
extern "C" void __jc_52(void* obj, unsigned long nargs, void** args, void* ret)
{
if (ret) {
new (ret) (bool) (((bool (&)(bool (&)()))callme_ref)((bool ()&)*(bool ()*)args[0]));
return;
}
else {
(void)(((bool (&)(bool (&)()))callme_ref)((bool ()&)*(bool ()*)args[0]));
return;
}
}
Required code:
- new (ret) (bool) (((bool (&)(bool (&)()))callme_ref)((bool ()&)*(bool ()*)args[0]));
+ new (ret) (bool) (((bool (&)(bool (&)()))callme_ref)((bool(&)())*(bool(*)())args[0]));
What operating system was you using when the bug occured?
No response
What is the architechture of the cpu on your system?
No response
What did you build CppInterOp against?
No response
Description of bug
The following test fails:
Note the pointer function works fine, i.e.
bool callme_ptr(bool (f)()) { return f(); }. The reference version does not compile.Code generated:
Required code:
What operating system was you using when the bug occured?
No response
What is the architechture of the cpu on your system?
No response
What did you build CppInterOp against?
No response