gcc 8+ throws warning during imaxdiv.c compilation:

  misc/imaxdiv.c:34:1: warning: ‘lldiv’ alias between functions of incompatible 
types ‘lldiv_t(long long int,  long long int)’ {aka ‘struct <anonymous>(long 
long int,  long long int)’} and ‘imaxdiv_t(intmax_t,  intmax_t)’ {aka ‘struct 
<anonymous>(long long int,  long long int)’} [-Wattribute-alias]
    lldiv (long long, long long);
    ^~~~~
  misc/imaxdiv.c:23:1: note: aliased declaration here
    imaxdiv(intmax_t numer, intmax_t denom)

lldiv_t and imaxdiv_t structures are compatible, they have same members,
just defined for each function separately. This is how they are defined
also in MS VC++ header files.

Warning could be avoided by using typedef between structures, but this may
cause problems for C++ applications which overloaded functions which have
lldiv_t or imaxdiv_t parameters.

So rather locally disable this warning for gcc. Current code should be OK.
---
 mingw-w64-crt/misc/imaxdiv.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/mingw-w64-crt/misc/imaxdiv.c b/mingw-w64-crt/misc/imaxdiv.c
index 36800046f5a0..8a6fb02c5d93 100644
--- a/mingw-w64-crt/misc/imaxdiv.c
+++ b/mingw-w64-crt/misc/imaxdiv.c
@@ -29,8 +29,19 @@ imaxdiv(intmax_t numer, intmax_t denom)
 }
 imaxdiv_t (__cdecl *__MINGW_IMP_SYMBOL(imaxdiv))(intmax_t, intmax_t) = imaxdiv;
 
+/*
+ * avoid gcc 8+ warning:
+ * 'lldiv' alias between functions of incompatible types 'lldiv_t(long long 
int,  long long int)' {aka 'struct <anonymous>(long long int,  long long int)'} 
and 'imaxdiv_t(intmax_t,  intmax_t)' {aka 'struct <anonymous>(long long int,  
long long int)'}
+ */
+#if defined(__GNUC__) && __GNUC__ >= 8
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wattribute-alias"
+#endif
 lldiv_t __attribute__ ((alias ("imaxdiv")))
 __cdecl
 lldiv (long long, long long); 
 extern lldiv_t __attribute__ ((alias 
(__MINGW64_STRINGIFY(__MINGW_IMP_SYMBOL(imaxdiv)))))
 (__cdecl *__MINGW_IMP_SYMBOL(lldiv))(long long, long long);
+#if defined(__GNUC__) && __GNUC__ >= 8
+#pragma GCC diagnostic pop
+#endif
-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to