From owner-svn-src-all@freebsd.org Thu Nov 30 00:47:45 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D10A5DEF0EF; Thu, 30 Nov 2017 00:47:45 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail108.syd.optusnet.com.au (mail108.syd.optusnet.com.au [211.29.132.59]) by mx1.freebsd.org (Postfix) with ESMTP id 20F8D6C0D6; Thu, 30 Nov 2017 00:47:45 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail108.syd.optusnet.com.au (Postfix) with ESMTPS id 036D91A63D9; Thu, 30 Nov 2017 11:46:20 +1100 (AEDT) Date: Thu, 30 Nov 2017 11:46:20 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Alex Richardson cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r326375 - head/share/mk In-Reply-To: <201711292116.vATLGEB2091742@repo.freebsd.org> Message-ID: <20171130110747.B1188@besplex.bde.org> References: <201711292116.vATLGEB2091742@repo.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=KeqiiUQD c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=kj9zAlcOel0A:10 a=6I5d2MoRAAAA:8 a=HgAegpf116_E81IoGS0A:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Nov 2017 00:47:45 -0000 On Wed, 29 Nov 2017, Alex Richardson wrote: > Log: > Don't fail the build due to clang integer constant range warnings > > This warning checks whether a constant is out of range of the integer > type. An example is `comparison of 'u_int' > 4294967295 is always false` > and in this case the warning makes sense. > However, when the type is a typedef that can be either 64 or 32 bits the > if condition is only tautological in some configurations so this should > not be a warning that fails the build. Even when the type is not a typedef, its limits are MD (except POSIX specifies precise limits for unsigned char and signed char). > Reviewed by: dim > Approved by: jhb (mentor) > Differential Revision: https://reviews.freebsd.org/D12912 > > Modified: > head/share/mk/bsd.sys.mk > > Modified: head/share/mk/bsd.sys.mk > ============================================================================== > --- head/share/mk/bsd.sys.mk Wed Nov 29 20:44:40 2017 (r326374) > +++ head/share/mk/bsd.sys.mk Wed Nov 29 21:16:14 2017 (r326375) > @@ -81,6 +81,9 @@ CWARNFLAGS.clang+= -Wno-unused-local-typedef > .if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 40000 > CWARNFLAGS.clang+= -Wno-address-of-packed-member > .endif > +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 60000 > +CWARNFLAGS.clang+= -Wno-error=tautological-constant-compare > +.endif > .endif # WARNS <= 3 > .if ${WARNS} <= 2 > CWARNFLAGS.clang+= -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter But this breaks the warning in all cases. There are related problems for signedness, especially for typedefed types and plain char. Robust code must not assume any particular signedness unless the type is documented as unsigned integral, so it checks for < 0. Then if compilers warn about tautological comparisons with 0, the warnings are usually "fixed" by removing the checks. Then if the type or typedef is changed to signed, the code breaks. It is better to break the warning as above. Bruce