On Fri, Aug 10, 2018 at 6:08 PM, Sam McCall <sam.mcc...@gmail.com> wrote: > json::Value in JSON.h is a discriminated union. > The storage is a char array of appropriate type and alignment. The storage > holds one object at a time, it's initialized (and for nontrivial types, > destroyed) at the right times to ensure this. The cast is only to the type > of object that's already there, there's no magic here. > > > On Fri, Aug 10, 2018, 17:52 Andrew Haley <a...@redhat.com> wrote: >> >> Not exactly. You can cast a pointer to a pointer to some character >> type or the type of the object stored in memory. It does not matter >> whether you use an intermediate type or not. Having not seen the test >> case, I can't tell whether this rule is followed.
Yes, if Andrew's explanation agrees with the standard, then this code should be benign (if it breaks any of these rules, that's a bug in and of itself). So maybe we're back to figuring out how to silence GCC's warning machinery :) - Kim