[PATCH] D50608: [Alt] Silence GCC warning about broken strict aliasing rules
Sam McCall via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 12 08:49:58 PDT 2018
sammccall accepted this revision.
sammccall added a comment.
I also prefer this version over suppressing the warning with the pragma.
Thanks!
================
Comment at: include/llvm/Support/JSON.h:456
+ // Using this double static_cast<> via void * instead of reinterpret_cast<>
+ // silences a -Wstrict-aliasing warning from GCC.
+ void *p = static_cast<void *>(Union.buffer);
----------------
Nit: seems worth mentioning that the warning is a false positive, and the upper bound on GCC version (so we know when it's obsolete)
================
Comment at: include/llvm/Support/JSON.h:457
+ // silences a -Wstrict-aliasing warning from GCC.
+ void *p = static_cast<void *>(Union.buffer);
+ return *static_cast<T *>(p);
----------------
nit: I guess this should be `P` (or `Storage`)
Repository:
rL LLVM
https://reviews.llvm.org/D50608
More information about the llvm-commits
mailing list