diff options
author | Theophile Ranquet <ranquet@lrde.epita.fr> | 2013-01-29 22:35:04 +0100 |
---|---|---|
committer | Theophile Ranquet <ranquet@lrde.epita.fr> | 2013-02-01 15:06:20 +0100 |
commit | be6fa942acae21a4a025bac5e339451be6ad136d (patch) | |
tree | 1710e06975e3bca48f607d070dc077d62cbeeb2e /configure.ac | |
parent | f29f8af3edf5b678f812e36ea4416983467e9189 (diff) | |
download | bison-be6fa942acae21a4a025bac5e339451be6ad136d.tar.gz |
variants: avoid type punning issue
This is based on what is recommended by both Scott Meyers, in 'Effective
C++', and Andrei Alexandrescu and Herb Sutter in 'C++ Coding Standards'.
Use a static_cast on void* rather than directly use a reinterpret_cast,
which can have nefarious effects on objects. However, even though following
this guideline is good practice in general, I am not quite sure how relevant
it is when applied to conversions from POD to objects. Actually, it might
very well be the opposite: isn't this exactly what reinterpret_cast is for?
What we really want *is* to transmit the memory map as a series of bytes,
which, if I am correct, falls into the kind of "low level" hack for which
this cast is meant.
In any case, this silences the warning, which will be greatly appreciated by
anyone using variants with a compiler supporting -fstrict-aliasing.
* data/variant.hh (as): Here.
* tests/c++.at (Exception safety, C++ Variant-based Symbols, Variants):
Don't use NO_STRICT_ALIAS_CXXFLAGS (revert commit ddb9db15), as type punning
is no longer an issue.
* tests/atlocal.in, configure.ac (NO_STRICT_ALIAS_CXXFLAGS): Remove
definition.
* examples/local.mk (NO_STRICT_ALIAS_CXXFLAGS): Remove from AM_CXXFLAGS.
* doc/bison.texi: Don't mention type punning issues.
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac index f10dabc1..05a8d920 100644 --- a/configure.ac +++ b/configure.ac @@ -144,8 +144,6 @@ if test "$enable_gcc_warnings" = yes; then done # Clang++ 3.2+ reject C code generated by Flex. gl_WARN_ADD([-Wno-null-conversion], [WARN_NO_NULL_CONVERSION_CXXFLAGS]) - # Variants break strict aliasing analysis. - gl_WARN_ADD([-fno-strict-aliasing], [NO_STRICT_ALIAS_CXXFLAGS]) CXXFLAGS=$save_CXXFLAGS AC_LANG_POP([C++]) fi |