From 62cac8e84bf0d1795fdaed9622dcfeaee41b93cd Mon Sep 17 00:00:00 2001 From: vlefevre Date: Tue, 2 Jul 2019 12:39:33 +0000 Subject: [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 --- src/mpfr-impl.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 -- cgit v1.2.1