diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-03-06 13:57:53 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-03-06 13:57:53 +0000 |
commit | 52201e28c1334fb1ff8dab1b57c386f4b0ee2f55 (patch) | |
tree | 4c752014f084aab3b03542d1ec64261f62f9cd52 /doc/README.dev | |
parent | ce590af8525020d476d4a3c000ddcfb975f8de78 (diff) | |
download | mpfr-52201e28c1334fb1ff8dab1b57c386f4b0ee2f55.tar.gz |
[doc/README.dev] Added information on how to do type punning
(something we already did, but with no justification yet).
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@9333 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'doc/README.dev')
-rw-r--r-- | doc/README.dev | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/doc/README.dev b/doc/README.dev index 46bc3ca5b..80d502626 100644 --- a/doc/README.dev +++ b/doc/README.dev @@ -501,6 +501,21 @@ Quoted from <http://www.gnu.org/software/gcc/codingconventions.html>: C-Reduce may be useful to try to identify whether a bug comes from the compiler. + ===================================================================== + +To do type punning (i.e. store a value of some type and reinterpret +it as another type), use a union. This is valid in ISO C99 and above +(in C99, see 6.5#7 and Note 82 of 6.5.2.3#3 for the clarification), +but not in C++. So, users of a C++ compilers should make sure that +their compiler supports type punning via a union. If some problem is +reported, we should address it either by making the code compatible +or by adding a configure test to reject the compiler. + +Some references: +* https://en.wikipedia.org/wiki/Type_punning#Use_of_union +* http://stackoverflow.com/questions/346622/opinions-on-type-punning-in-c + "Opinions on type-punning in C++?" + =========================================================================== Avoid variable names "l", "I" and "O", which look like "1" and "0" with |