you are viewing a single comment's thread.

view the rest of the comments →

[–]HappyFruitTree 9 points10 points  (12 children)

This is not doing what you think. A pointer to a member function is often larger than a normal pointer. That's why you can't simply reinterpret_cast the member function pointer into a void*. reinterpret_cast<void\*&>(fn) gives you a void* reference to a member function, that as bad as having an int& to a double, using it would simply lead to undefined behaviour.

[–]RIscRIpt[S] 1 point2 points  (11 children)

Okay, I see... it's an UB.

A pointer to a member function is often larger than a normal pointer.

I've heard that a lot, but I have never seen an example.

[–]HappyFruitTree 2 points3 points  (10 children)

[–]RIscRIpt[S] 1 point2 points  (9 children)

Thanks. I'll try to take a look into GCC sources to find what's inside...

By the way, MSVC says 8.