Sam McCall via llvm-dev
2018-Aug-09 11:25 UTC
[llvm-dev] GCC 5 and -Wstrict-aliasing in JSON.h
Author of the problematic code here. Thanks everyone, and sorry to have caused difficulty! 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?) Still if there's a simple source-level workaround, or we can suppress the warning with a #pragma, I'd be happy to do that. GCC 4.9.3 is a supported compiler for LLVM and the more configurations we build cleanly in, the better. If this is a useful direction, could someone with an affected environment send me a small patch? I don't have the right setup to verify myself. Cheers, Sam -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180809/b07dae61/attachment.html>
Jonathan Wakely via llvm-dev
2018-Aug-09 22:02 UTC
[llvm-dev] GCC 5 and -Wstrict-aliasing in JSON.h
On Thu, 9 Aug 2018 at 22:59, Kim Gräsman <kim.grasman at gmail.com> wrote:> > Thanks all for pitching in to help! > > On Thu, Aug 9, 2018 at 1:25 PM, Sam McCall <sam.mccall at gmail.com> 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 me firmly > incompetent to judge what's valid and not :) > > But since both Clang and GCC 6+ are happy with this, it seems > plausible that this would be a false positive.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 warns. Unless you're sure that not only is the code OK, but GCC is just being noisy and doesn't misoptimise, then I think using -fno-strict-aliasing is safer than just suppressing the warning.> > Still if there's a simple source-level workaround, or we can suppress the > > warning with a #pragma, I'd be happy to do that. GCC 4.9.3 is a supported > > compiler for LLVM and the more configurations we build cleanly in, the > > better. > > I *think* Leslie's warning-disable patch should work even with MSVC > (it should ignore unknown #pragmas, right?). I can't think of a > straight-up code change that would fix this. > > Cheers, > - Kim