Re: [llvm-dev] GCC 5 and -Wstrict-aliasing in JSON.h

2018-08-10 Thread Kim Gräsman
On Fri, Aug 10, 2018 at 6:08 PM, Sam McCall 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

Re: [llvm-dev] GCC 5 and -Wstrict-aliasing in JSON.h

2018-08-10 Thread Kim Gräsman
Hi LH_Mouse, Thanks! On Fri, Aug 10, 2018 at 6:30 AM, Liu Hao wrote: > > When I used to do such type punning in C, I got similar warnings. Then I > looked for some solutions... I can't recall the principle now and I fail to > find it in the C or C++ standard. Despite that, the solution is simple

Re: [llvm-dev] GCC 5 and -Wstrict-aliasing in JSON.h

2018-08-09 Thread Kim Gräsman
On Fri, Aug 10, 2018 at 12:02 AM, Jonathan Wakely wrote: > > If GCC 4.9.3 thinks there's an aliasing violation it might > misoptimise. It doesn't matter if it's right or not, it matters if it > treats the code as undefined or not. > > And apparently GCC does think there's a violation, because it w

Re: [llvm-dev] GCC 5 and -Wstrict-aliasing in JSON.h

2018-08-09 Thread Kim Gräsman
Thanks all for pitching in to help! On Thu, Aug 9, 2018 at 1:25 PM, Sam McCall wrote: > > Obviously if there really is something illegal here we should fix it in > LLVM, but it looks like this warning is a false positive (anyone disagree?) The little I've read about strict aliasing rules leaves