c++ - Does FlatBuffers avoid strict aliasing somehow? -



c++ - Does FlatBuffers avoid strict aliasing somehow? -

i have been looking @ flatbuffers library recently. looking evaluate utilize in project. upon looking @ flatbuffers.h, wondering if there violation of strict-aliasing rule , if business relationship strict aliasing, can explain how this?

in previous projects, have learned rule hard way, optimization gives subtle bugs hard find. i've been using placement new operator avoid using compiler flags business relationship this.

links:

flatbuffers.h

strict-aliasing rule

placement new operator

currently, reading flatbuffer exclusively read affair, compiler assume no pointers alias, , should not create problems.

writing flatbuffer perchance trickier, here each piece of memory touched 1 time single pointer, , never gets read back, except vtable comparisons in endtable() (which read memcmp()).

then in theory, if first build flatbuffer , read it, optimize across writing , reading code, , "evil" optimisations of kind linus referring in link above (pretend writing never happened).

the code clean w.r.t. -fstrict-aliasing -wstrict-aliasing=3, not that gives guarantees.

if there's code in particular sense unsafe, or have ideas on how improve protect against aliasing issues (that not -fno-strict-aliasing :), i'd love hear.

c++ strict-aliasing flatbuffers

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -