Remove one case of UB union work

This commit is contained in:
Jason Turner 2017-10-02 09:52:51 -06:00
parent 2662395cac
commit 15196af5d6

View File

@ -41,7 +41,7 @@ namespace chaiscript
struct DLSym
{
DLSym(DLModule &t_mod, const std::string &t_symbol)
: m_symbol(cast_symbol(dlsym(t_mod.m_data, t_symbol.c_str())))
: m_symbol(reinterpret_cast<T>(dlsym(t_mod.m_data, t_symbol.c_str())))
{
if (!m_symbol)
{
@ -49,19 +49,6 @@ namespace chaiscript
}
}
static T cast_symbol(void *p)
{
union cast_union
{
T func_ptr;
void *in_ptr;
};
cast_union c;
c.in_ptr = p;
return c.func_ptr;
}
T m_symbol;
};