BitFunnel / NativeJIT

A C++ expression -> x64 JIT

Home Page:http://bitfunnel.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compilation error: dereferencing type-punned pointer

joto opened this issue · comments

When compiling with GCC 6 I get errors: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] in multiple places. Easy to work around by disabling this check, but a more permanent solution would be better.

Could you please post the exact gcc version you're using? I tried with 6.1.0 and couldn't reproduce the issue. Given that 6.2 is out, I should probably give that a shot.

g++ (Debian 6.1.1-11) 6.1.1 20160802

Interesting. I installed 6.2.0 and wasn't able to reproduce this with 6.2.0 either. I can try getting the exact same version, but since the build works with both earlier and later versions on my machine, I wonder if there's some ingredient other than just the gcc version.

I tested some more. It only happens in Release builds, not Dev. So using the current master and then calling cmake -DCMAKE_BUILD_TYPE=Release.

Here are the places I see this happen:

nativejit/inc/NativeJIT/ExpressionTree.h:308:16: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
     return *(reinterpret_cast<T const *>(&m_immediate));
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

nativejit/inc/NativeJIT/ExpressionTree.h:294:9: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
     *reinterpret_cast<T*>(&m_immediate) = value;
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I believe this is fixed in dd865a6. Does this work for you?

Also, I had to add the flag to check for strict aliasing to reproduce. Is there any possibility that you're getting that flag added when you do a release build?

Yes, thanks. The fix works. Don't know where the setting comes from, but maybe Debian compiles GCC differently or so.