From 52201e28c1334fb1ff8dab1b57c386f4b0ee2f55 Mon Sep 17 00:00:00 2001 From: vlefevre Date: Fri, 6 Mar 2015 13:57:53 +0000 Subject: [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 --- doc/README.dev | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 : 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 -- cgit v1.2.1