Tautological comparison in gcc 6.1.1

Michael Adam obnox at samba.org
Thu Jul 14 08:25:21 UTC 2016


On 2016-07-14 at 09:52 +0200, Michael Adam wrote:
> On 2016-07-14 at 15:21 +1000, Martin Schwenke wrote:
> > On Thu, 14 Jul 2016 06:23:57 +0200, Stefan Metzmacher <metze at samba.org>
> > wrote:
> > 
> > > Am 14.07.2016 um 04:58 schrieb Ira Cooper:
> > > > On Wed, Jul 13, 2016 at 6:29 PM, Michael Adam <obnox at samba.org> wrote:
> > > >   
> > > >> On 2016-07-13 at 15:23 -0700, Jeremy Allison wrote:  
> > >  [...]  
> > >  [...]  
> > >  [...]  
> > >  [...]  
> > >  [...]  
> > >  [...]  
> > >  [...]  
> > >  [...]  
> > >  [...]  
> > > >>
> > > >> here it is
> > > >>
> > > >> Thanks - Michael
> > > >>  
> > > > 
> > > > I agree with Jeremy, this is u-g-l-y.  But there is no cleaner solution.  
> > > 
> > > We currently using:
> > > conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS', '-Werror
> > > -Wno-error=deprecated-declarations', testflags=True)
> > > can't we just add
> > > conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS', '-Wno-error=tautological-compare',
> > > testflags=True)
> > > ?
> > > 
> > > That would fix it for all cases not just the macros.
> > 
> > Samba/CTDB no longer builds on (unpatched) RHEL 6.6 with GCC 4.4.7.
> > 
> > [ 46/248] Compiling lib/tdb_wrap/tdb_wrap.c
> > ../lib/tdb_wrap/tdb_wrap.c: In function 'tdb_wrap_private_destructor':
> > ../lib/tdb_wrap/tdb_wrap.c:81: error: #pragma GCC diagnostic not allowed inside functions
> > ../lib/tdb_wrap/tdb_wrap.c:81: error: #pragma GCC diagnostic not allowed inside functions
> > ../lib/tdb_wrap/tdb_wrap.c:81: error: #pragma GCC diagnostic not allowed inside functions
> > ../lib/tdb_wrap/tdb_wrap.c:81: error: #pragma GCC diagnostic not allowed inside functions
> > 
> > GCC version is:
> > 
> >   gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11)
> > 
> > RHEL 6.8 has a later build but the changelog doesn't mention any
> > changes to pragma magic.
> > 
> > It will have to be either
> >
> > "#ifdef gcc >= 6" around the _Pragma hunks.
> 
> Guess that does not work, because it is inside
> a macro: This is why we used _Pragma instead
> of #pragma. And the ignore -Wpramgas was intended
> to fix older gccs, but apparently I did not test
> with old enough gcc. :-/
> 
> Apologies for the inconvenience..
> 
> > global "-Wno-error=tautological-compare" or
> 
> Right, what our patch was trying to avoid was getting
> rid of the other possibly useful cases of -Wtautological-compare
> but if everyone agrees, then we can just silence
> them altogether with a global setting...
> 
> Will propose another patch...

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
-------------- next part --------------
From 9738fd6042516563675074feca31803d39d6c765 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 a17b866be765bcb7be5c680c3534376d394cf136 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 72dead7692b67d3fc97db1fd25361aa8bf8c67fe 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 7e999effb199c9f997e62154a257016cf8931262 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..5160003 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=deprecated-declarations', 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/f6f58260/signature.sig>


More information about the samba-technical mailing list