Closed lukaszrachwalski closed 4 years ago
This is not a bug. It's a feature:
lib.get<void()>("func")
imports a function void func(){}
lib.get<void(*)()>("func_var")
imports a variable auto func_var = &func
P.S.: I'd appreciate a PR to clarify that behavior in FAQ section of the docs
Hi, I have no permission to create branch in this repository. BTW The only comment I can leave in FAQ section is a short description this problematic case that could look like this:
* [*Question:] Can I use function pointer type instead of function type to import function symbols?
* [*Answer:] No you can't. The address you get is not the address to the function pointer you want. Even though your code is compiled correctly, the application will crash with SegFault at the first try to call the function.
It would be much better reduce number of wrong usages of the library by adding some mechanism to forbid using function pointers or returning the correct address to function pointer by choosing the correct version of the overload lib.get()
member function.
Thanks for the report!
Added infor into FAQ
I have come across this issue when using function pointer type instead of function type. In this case calling a function after getting symbol address causes application crash: segmentation fault.
OS: Ubuntu 18.04.4 LTS Compiler: clang 9 Boost version is: 1.67.0
Please check attached example: BoostDllTest.zip