summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2017-11-28 15:07:33 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2017-11-28 15:07:33 +0000
commite1c1a450f1dd46584ea913e4f90ee803a25b8cc3 (patch)
treeb3753abef3d1cbf06f1852684385497b96e2c417
parent0094251ba4bed895e6759663f9a8952373c13b5d (diff)
downloadmpfr-e1c1a450f1dd46584ea913e4f90ee803a25b8cc3.tar.gz
[src/fpif.c] Added static assertions in mpfr_fpif_import().
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@11851 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--src/fpif.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/fpif.c b/src/fpif.c
index cacc0a0c5..9f3abfdd0 100644
--- a/src/fpif.c
+++ b/src/fpif.c
@@ -597,6 +597,13 @@ mpfr_fpif_import (mpfr_t x, FILE *fh)
for the test. */
if (!MPFR_IS_SINGULAR (x))
{
+ /* For portability, we need to consider bytes with only 8 significant
+ bits in the interchange format. That's OK because CHAR_BIT >= 8.
+ But the implementation is currently not clear when CHAR_BIT > 8.
+ This may have never been tested. For safety, require CHAR_BIT == 8,
+ and test/adapt the code if this ever fails. */
+ MPFR_STAT_STATIC_ASSERT (CHAR_BIT == 8);
+ MPFR_STAT_STATIC_ASSERT ((MPFR_PREC_MAX + 7) >> 3 <= (size_t) -1);
used_size = (precision + 7) >> 3; /* ceil(precision/8) */
buffer = (unsigned char*) mpfr_allocate_func (used_size);
if (buffer == NULL)