diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2019-07-02 12:39:33 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2019-07-02 12:39:33 +0000 |
commit | 62cac8e84bf0d1795fdaed9622dcfeaee41b93cd (patch) | |
tree | 4e5f71d5563eea92a0127c1bd1fe3aab368919b3 | |
parent | 6143bc67d7dece48d859c373c904d6388b2b8370 (diff) | |
download | mpfr-62cac8e84bf0d1795fdaed9622dcfeaee41b93cd.tar.gz |
[src/mpfr-impl.h] MPFR_GROUP_* macros / mpfr_group_t structure: when
MPFR_GROUP_STATIC_SIZE is 0 (for testing), use a flexible array member
(ISO C99) instead of a zero-length array (GNU extension, forbidden in
ISO C).
(merged changeset r13517 from the trunk)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/4.0@13518 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | src/mpfr-impl.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mpfr-impl.h b/src/mpfr-impl.h index e2a2dd0d9..98e2d2325 100644 --- a/src/mpfr-impl.h +++ b/src/mpfr-impl.h @@ -2026,7 +2026,21 @@ __MPFR_DECLSPEC extern mpfr_prec_t mpfr_log_prec; struct mpfr_group_t { size_t alloc; mp_limb_t *mant; +#if MPFR_GROUP_STATIC_SIZE != 0 mp_limb_t tab[MPFR_GROUP_STATIC_SIZE]; +#else + /* In order to detect memory leaks when testing, MPFR_GROUP_STATIC_SIZE + can be set to 0, in which case tab will not be used. ISO C does not + support zero-length arrays[*], thus let's use a flexible array member + (which will be equivalent here). Note: this is new in C99, but this + is just used for testing. + [*] Zero-length arrays are a GNU extension: + https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html + and as such an extension is forbidden in ISO C, it triggers an + error with -Werror=pedantic. + */ + mp_limb_t tab[]; +#endif }; #define MPFR_GROUP_DECL(g) struct mpfr_group_t g |