Discussion:
[PATCH] m4: Remove ternary operator from extern-inline
(too old to reply)
Martin Kletzander
2017-06-05 13:03:19 UTC
Permalink
Raw Message
When compiling libvirt with updated GCC (v7.1.0), the following warning
pops out (which then ends up treated like an error):

../config.h:2994:48: error: this use of "defined" may not be portable [-Werror=expansion-to-defined]
|| (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \

If I remove the ternary operator, the warning/error goes away.

Signed-off-by: Martin Kletzander <***@redhat.com>
---
I did not check that the define works the same way on all platforms, I
do not have all of those available. However I did my best when trying
to express the same conditions.

Ideas welcome. If there's another way of approaching it (or someone
else already works on this and I missed it), feel free to tell me
straight away. Thanks.

m4/extern-inline.m4 | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/m4/extern-inline.m4 b/m4/extern-inline.m4
index 00f960968b01..2c418bd4ef8d 100644
--- a/m4/extern-inline.m4
+++ b/m4/extern-inline.m4
@@ -39,16 +39,18 @@ AC_DEFUN([gl_EXTERN_INLINE],
OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and
for clang but remains for g++; see <http://trac.macports.org/ticket/41033>.
Assume DragonFly and FreeBSD will be similar. */
-#if (((defined __APPLE__ && defined __MACH__) \
- || defined __DragonFly__ || defined __FreeBSD__) \
- && (defined __header_inline \
- ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \
- && ! defined __clang__) \
- : ((! defined _DONT_USE_CTYPE_INLINE_ \
- && (defined __GNUC__ || defined __cplusplus)) \
- || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
- && defined __GNUC__ && ! defined __cplusplus))))
+# if ((defined __APPLE__ && defined __MACH__) \
+ || defined __DragonFly__ || defined __FreeBSD__)
+# if defined __header_inline
+# if defined __cplusplus && defined __GNUC_STDC_INLINE__ && ! defined __clang__
+# define _GL_EXTERN_INLINE_STDHEADER_BUG
+# endif
+# elif ((! defined _DONT_USE_CTYPE_INLINE_ \
+ && (defined __GNUC__ || defined __cplusplus)) \
+ || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
+ && defined __GNUC__ && ! defined __cplusplus))
# define _GL_EXTERN_INLINE_STDHEADER_BUG
+# endif
#endif
#if ((__GNUC__ \
? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
--
2.13.0
Bruno Haible
2017-06-05 14:14:38 UTC
Permalink
Raw Message
Hi,
Post by Martin Kletzander
When compiling libvirt with updated GCC (v7.1.0), the following warning
../config.h:2994:48: error: this use of "defined" may not be portable [-Werror=expansion-to-defined]
|| (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
If I remove the ternary operator, the warning/error goes away.
This warning (-Wexpansion-to-defined) is documented in [1]:

Warn whenever ‘defined’ is encountered in the expansion of a macro
(including the case where the macro is expanded by an ‘#if’ directive).

What is the expansion of _FORTIFY_SOURCE in your case?
(You can use "gcc -E -dM" to determine it.)

If it does contain the 'defined' keyword, please fix that.

If not, you have found a GCC bug. Please report it at [2].
And disable -Werror until it gets fixed. Gnulib does *not* support the use of
-Werror. [3]

Bruno

[1] https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/Warning-Options.html
[2] https://gcc.gnu.org/bugs/
[3] https://www.gnu.org/software/gnulib/manual/html_node/warnings.html
Martin Kletzander
2017-06-06 15:11:47 UTC
Permalink
Raw Message
Hi,
Post by Martin Kletzander
When compiling libvirt with updated GCC (v7.1.0), the following warning
../config.h:2994:48: error: this use of "defined" may not be portable [-Werror=expansion-to-defined]
|| (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
If I remove the ternary operator, the warning/error goes away.
Warn whenever ‘defined’ is encountered in the expansion of a macro
(including the case where the macro is expanded by an ‘#if’ directive).
What is the expansion of _FORTIFY_SOURCE in your case?
(You can use "gcc -E -dM" to determine it.)
If it does contain the 'defined' keyword, please fix that.
It certainly does! Thank you very much for your time and the helpful
information. It was the build system of my distribution what actually
caused this issue. So I provided a fix for that.

Have a nice day,
Martin
If not, you have found a GCC bug. Please report it at [2].
And disable -Werror until it gets fixed. Gnulib does *not* support the use of
-Werror. [3]
Bruno
[1] https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/Warning-Options.html
[2] https://gcc.gnu.org/bugs/
[3] https://www.gnu.org/software/gnulib/manual/html_node/warnings.html
Bruno Haible
2017-06-06 16:04:54 UTC
Permalink
Raw Message
Post by Bruno Haible
If it does contain the 'defined' keyword, please fix that.
It certainly does! ... It was the build system of my distribution what actually
caused this issue. So I provided a fix for that.
Thanks to you, for having communicated the result of your investigations (i.e.
having confirmed that it was not a bug in Gnulib).

Bruno

Loading...