Date: Thu, 30 Nov 2017 11:46:20 +1100 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Alex Richardson <arichardson@freebsd.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r326375 - head/share/mk Message-ID: <20171130110747.B1188@besplex.bde.org> In-Reply-To: <201711292116.vATLGEB2091742@repo.freebsd.org> References: <201711292116.vATLGEB2091742@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20171130110747.B1188>