Tautological comparison in gcc 6.1.1

Michael Adam obnox at samba.org
Thu Jul 14 09:11:16 UTC 2016


On 2016-07-14 at 18:45 +1000, Amitay Isaacs wrote:
> On Thu, Jul 14, 2016 at 6:25 PM, Michael Adam <obnox at samba.org> wrote:
> 
> >
> > Attached.
> > It reverts the previous 3 patches and
> > establishes the global no-error for taut.-comp.
> >
> > Tested with gcc 6 and gcc 4.8 this time.
> >
> > Cheers - Michael
> >
> 
> Reviewed-by: Amitay Isaacs <amitay at gmail.com>
> 
> This is definitely a better option.  You get the warnings, but does not
> stop you from using --picky-developer.

Umm, embarrassing: As Annop CS pointed out to me,
I made a copy-and-paste error in my patch, to the
effect of adding -Wno-error=deprecated-declarations
again instead of -Wno-error=tautological-compare ...

Secondly, I thought I tested with gcc6 but I only
tested with gcc5.

Finally, Amitay seems to have trusted my word that
I tested with gcc6. ;-)

The updated corrected patchset should finally fix it. :-D

Cheers - Michael
-------------- next part --------------
From f219c79a3c57d4f6ce4bbbbf3823178878d22be2 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 14 Jul 2016 09:57:32 +0200
Subject: [PATCH 1/4] Revert "ldb:dlinklist: avoid -Wtautological-compare
 errors with gcc6"

This reverts commit 7c9505e651287c5d4747b222af1fda970c562a00.

Breaks compile for older (<= 4.4) gccs.
Needs to be done differently.

Signed-off-by: Michael Adam <obnox at samba.org>
---
 lib/ldb/include/dlinklist.h | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/lib/ldb/include/dlinklist.h b/lib/ldb/include/dlinklist.h
index ca76794..ef01aec 100644
--- a/lib/ldb/include/dlinklist.h
+++ b/lib/ldb/include/dlinklist.h
@@ -83,9 +83,6 @@ do { \
 */
 #define DLIST_REMOVE(list, p) \
 do { \
-	_Pragma ("GCC diagnostic push") \
-	_Pragma ("GCC diagnostic ignored \"-Wpragmas\"") \
-	_Pragma ("GCC diagnostic ignored \"-Wtautological-compare\"") \
 	if ((p) == (list)) { \
 		if ((p)->next) (p)->next->prev = (p)->prev; \
 		(list) = (p)->next; \
@@ -97,7 +94,6 @@ do { \
 		if ((p)->next) (p)->next->prev = (p)->prev; \
 	} \
 	if ((p) != (list)) (p)->next = (p)->prev = NULL;	\
-	_Pragma ("GCC diagnostic pop") \
 } while (0)
 
 /*
@@ -128,11 +124,7 @@ do { \
 		(p)->next = (el)->next;		\
 		(el)->next = (p);		\
 		if ((p)->next) (p)->next->prev = (p);	\
-		_Pragma ("GCC diagnostic push") \
-		_Pragma ("GCC diagnostic ignored \"-Wpragmas\"") \
-		_Pragma ("GCC diagnostic ignored \"-Wtautological-compare\"") \
 		if ((list)->prev == (el)) (list)->prev = (p); \
-		_Pragma ("GCC diagnostic pop") \
 	}\
 } while (0)
 
-- 
2.5.5


From b826cd63cd0b6febe49f9e74c8f93bb64f289f84 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 14 Jul 2016 09:58:15 +0200
Subject: [PATCH 2/4] Revert "tevent: avoid -Wtautological-compare errors with
 gcc6"

This reverts commit 2991f7709973fdcc2c0b83bbe15dda3f1ceae9b3.

Breaks compile for older (<= 4.4) gccs.
Needs to be done differently.

Signed-off-by: Michael Adam <obnox at samba.org>
---
 lib/tevent/tevent_util.h | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/lib/tevent/tevent_util.h b/lib/tevent/tevent_util.h
index eb7586f..e2cdbb8 100644
--- a/lib/tevent/tevent_util.h
+++ b/lib/tevent/tevent_util.h
@@ -79,9 +79,6 @@ do { \
 */
 #define DLIST_REMOVE(list, p) \
 do { \
-	_Pragma ("GCC diagnostic push") \
-	_Pragma ("GCC diagnostic ignored \"-Wpragmas\"") \
-	_Pragma ("GCC diagnostic ignored \"-Wtautological-compare\"") \
 	if ((p) == (list)) { \
 		if ((p)->next) (p)->next->prev = (p)->prev; \
 		(list) = (p)->next; \
@@ -93,7 +90,6 @@ do { \
 		if ((p)->next) (p)->next->prev = (p)->prev; \
 	} \
 	if ((p) != (list)) (p)->next = (p)->prev = NULL;	\
-	_Pragma ("GCC diagnostic pop") \
 } while (0)
 
 /*
@@ -124,11 +120,7 @@ do { \
 		(p)->next = (el)->next;		\
 		(el)->next = (p);		\
 		if ((p)->next) (p)->next->prev = (p);	\
-		_Pragma ("GCC diagnostic push") \
-		_Pragma ("GCC diagnostic ignored \"-Wpragmas\"") \
-		_Pragma ("GCC diagnostic ignored \"-Wtautological-compare\"") \
 		if ((list)->prev == (el)) (list)->prev = (p); \
-		_Pragma ("GCC diagnostic pop") \
 	}\
 } while (0)
 
-- 
2.5.5


From 2b9703623b97f40c4d3042cdc1f1426886a2d3c5 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 14 Jul 2016 09:58:28 +0200
Subject: [PATCH 3/4] Revert "lib:dlinklist: avoid -Wtautological-compare
 errors with gcc6"

This reverts commit 5d85fd85467eb1f8941641d5f71d75e7d5c7234c.

Breaks compile for older (<= 4.4) gccs.
Needs to be done differently.

Signed-off-by: Michael Adam <obnox at samba.org>
---
 lib/util/dlinklist.h | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/lib/util/dlinklist.h b/lib/util/dlinklist.h
index bdd4f9c..8a1b84d 100644
--- a/lib/util/dlinklist.h
+++ b/lib/util/dlinklist.h
@@ -79,9 +79,6 @@ do { \
 */
 #define DLIST_REMOVE(list, p) \
 do { \
-	_Pragma ("GCC diagnostic push") \
-	_Pragma ("GCC diagnostic ignored \"-Wpragmas\"") \
-	_Pragma ("GCC diagnostic ignored \"-Wtautological-compare\"") \
 	if ((p) == (list)) { \
 		if ((p)->next) (p)->next->prev = (p)->prev; \
 		(list) = (p)->next; \
@@ -93,7 +90,6 @@ do { \
 		if ((p)->next) (p)->next->prev = (p)->prev; \
 	} \
 	if ((p) != (list)) (p)->next = (p)->prev = NULL;	\
-	_Pragma ("GCC diagnostic pop") \
 } while (0)
 
 /*
@@ -124,11 +120,7 @@ do { \
 		(p)->next = (el)->next;		\
 		(el)->next = (p);		\
 		if ((p)->next) (p)->next->prev = (p);	\
-		_Pragma ("GCC diagnostic push") \
-		_Pragma ("GCC diagnostic ignored \"-Wpragmas\"") \
-		_Pragma ("GCC diagnostic ignored \"-Wtautological-compare\"") \
 		if ((list)->prev == (el)) (list)->prev = (p); \
-		_Pragma ("GCC diagnostic pop") \
 	}\
 } while (0)
 
-- 
2.5.5


From f42944ddb4f2322abcebe10ee38a377325e6c871 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 14 Jul 2016 10:01:15 +0200
Subject: [PATCH 4/4] build: avoid -Wtautological-compare errors from gcc6+ by
 disabling it globally

Signed-off-by: Michael Adam <obnox at samba.org>
---
 buildtools/wafsamba/samba_autoconf.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index 09ce218..5f35d77 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -725,6 +725,7 @@ int main(void) {
 
     if Options.options.picky_developer:
         conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS', '-Werror -Wno-error=deprecated-declarations', testflags=True)
+        conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS', '-Wno-error=tautological-compare', testflags=True)
 
     if Options.options.fatal_errors:
         conf.ADD_CFLAGS('-Wfatal-errors', testflags=True)
-- 
2.5.5

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20160714/2ef5afb6/signature.sig>


More information about the samba-technical mailing list