fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. typedef int (*funct_ptr_good)(int, void *);
  5. typedef int (*funct_ptr_bad)();
  6.  
  7. void foo(funct_ptr_bad fb) {
  8. funct_ptr_good fg = reinterpret_cast<funct_ptr_good>(fb);
  9. fg(12345, NULL);
  10. }
  11.  
  12. int main() {
  13. funct_ptr_good fg = [] (int key, void * ptr) -> int {
  14. cout << key << " " << ptr << endl;
  15. return 0;
  16. };
  17. foo(reinterpret_cast<funct_ptr_bad>(fg));
  18. return 0;
  19. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
12345 0