-Wall creates strict-aliasing warnings on g++ 7 + opt
Issue #13
resolved
Building with g++ 7.1.0 OPTLEVEL=3 on Linux, we currently see the strict-aliasing warnings below for code in packing.hpp. I assume this type-punning is arising as a fundamental part of serialization and not easily removed.
Note this warning is being explicitly enabled by nobs via -Wall. We should probably either add -Wno-strict-aliasing and/or use the GCC diagnostic pragmas to suppress this warning for the code in question
/local/pkg/gcc/7.1.0/bin/g++ -std=c++11 -std=c++14 -pie -fpie' DBGSYM=0 OPTLEV=3 GASNET="/home/upcnightly/EX-dirac-udp-gcc/runtime/bld/opt/upcxx/gasnet/include" GASNET_CONDUIT=udp && nobs exe /home/upcnightly/EX-dirac-udp-gcc/runtime/bld/opt/upcxx/test/dist_object.cpp
...
/home/upcnightly/EX-dirac-udp-gcc/runtime/bld/opt/upcxx/.nobs/art/3f2c61107ec4b96868ac8381c805452b2effdae9/upcxx/packing.hpp:508:14: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
return *reinterpret_cast<std::uintptr_t*>(&tmp);
...
/home/upcnightly/EX-dirac-udp-gcc/runtime/bld/opt/upcxx/.nobs/art/3f2c61107ec4b96868ac8381c805452b2effdae9/upcxx/packing.hpp:516:14: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
return *reinterpret_cast<Fp*>(&tmp);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
/home/upcnightly/EX-dirac-udp-gcc/runtime/bld/opt/upcxx/.nobs/art/3f2c61107ec4b96868ac8381c805452b2effdae9/upcxx/packing.hpp:487:24: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
reflect_upon(re, *reinterpret_cast<T*>(&ooze));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/upcnightly/EX-dirac-udp-gcc/runtime/bld/opt/upcxx/.nobs/art/3f2c61107ec4b96868ac8381c805452b2effdae9/upcxx/packing.hpp:490:15: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
T ans = reinterpret_cast<T&&>(ooze);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/upcnightly/EX-dirac-udp-gcc/runtime/bld/opt/upcxx/.nobs/art/3f2c61107ec4b96868ac8381c805452b2effdae9/upcxx/packing.hpp:490:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
T ans = reinterpret_cast<T&&>(ooze);
^~~
/home/upcnightly/EX-dirac-udp-gcc/runtime/bld/opt/upcxx/.nobs/art/3f2c61107ec4b96868ac8381c805452b2effdae9/upcxx/packing.hpp:491:7: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
reinterpret_cast<T&>(ooze).~T();
^~~~~~~~~~~~~~~~~~~~~~~~~~
Comments (5)
-
reporter -
reporter - changed version to 2017.09.01 preview release
- changed component to Runtime
-
Account Deleted - changed status to resolved
Fixed issue 13: https://bitbucket.org/berkeleylab/upcxx/issues/13/wall-creates-strict-aliasing-warnings-on-g
Removed warning suppressions in favor of better type-punning code.
→ <<cset 24a92d318104>>
-
-
assigned issue to
-
assigned issue to
-
reporter - changed version to 2017.9 preview release
- Log in to comment
With some other fixes, this warning is now polluting a large fraction of our opt CI results.
I've programmatically suppressed the warning in f6c7c8c
Someone who understands the details of what this header is doing should probably investigate further.