From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani
On 06/15/2017 05:54 AM, Philipp Stephani wrote:
> I've considered a couple of options. I think the simplest and most=
> portable one would be to compile as C++, which has destructors built > into the language.
That would require some autoconf and makefile hacking, but it would
work. That is, if modules are enabled, and __attribute__ ((cleanup)) is
not available but a C++ compiler is available, then the build process
could use the C++ compiler. Admittedly this is low priority.Alternatively, we might even compile emacs-modules.c = as C++ unconditionally. I guess by now every system that has a C compiler a= nd supports shared libraries also has a C++ compiler.=C2=A0
> How about using #pragma clang diagnostic push/pop/ignore to ignore the=
> warnings in the specific statements where they arise and we know that<= br> > they are false positives? I'd much prefer that over disabling them=
> globally in configure, because most of the time the warnings are usefu= l.
Although many warnings are useful, in my experience these particular
warnings are not useful for Emacs. That is, the hassle they cause by
false alarms costs more than the benefits of actual bugs that they fix.
It's OK to disable such warnings globally.
>
>=C2=A0 =C2=A0 =C2=A0And I'm still puzzled as to why you're gett= ing the Clang warnings
>=C2=A0 =C2=A0 =C2=A0but I
>=C2=A0 =C2=A0 =C2=A0am not. Are you using an older Clang? Are you passi= ng it extra warning
>=C2=A0 =C2=A0 =C2=A0options?
>
>
> I'm using the Apple fork on macOS. It's mostly identical to up= stream
> Clang and compiles Emacs just fine, but it is a fork and not 100%
> identical. I also get some of the warnings only when building with -O3=
> (haven't checked other optimization levels).
I just now applied the attached patch, configured with:
./configure --enable-gcc-warnings CC=3Dclang CFLAGS=3D'-O3'
and had no problems on Fedora 25. If you have a problem with this patch,
can you please send relevant output from 'clang --version' and '= ;make
V=3D1'?On macOS 10.12.5, current mast= er, and the rlim_t patch reverted:$ git rev-parse = HEAD
1ac8c9bb9b6ba44585ed68b03ebbce659a777041$ gc= c -c=C2=A0 -Demacs= =C2=A0 -I. -I. -I.= ./lib -I../lib =C2=A0 -I/usr/X11/include = =C2=A0 =C2=A0 =C2=A0 -I/usr/local/Cellar/dbus/1.10.18/include/dbus-1= .0 -I/usr/local/Cellar/dbus/1.10.18/lib/dbus-1.0/include =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -= MMD -MF deps/emacs.d -MP= =C2=A0 -I/usr/local/Cellar/gnutls/3.5.13/include -I/usr/local/Cellar= /nettle/3.3/include -I/usr/local/Cellar/libtasn1/4.12/include -I/usr/local/= Cellar/p11-kit/0.23.7/include/p11-kit-1=C2=A0 =C2=A0 -Wno-switch -Wno-tautological-constant-o= ut-of-range-compare -Wno-pointer-sign -Wno-string-plus-int -Wno-unknown-att= ributes -ggdb3 -O0=C2=A0 = emacs.cemacs.c:835:1= 2: warning: comparison of 0 <=3D unsigned expression is a= lways true
=C2=A0 =C2=A0 =C2=A0 [-Wtauto= logical-compare]
=C2=A0 =C2=A0 =C2=A0 && 0 = <=3D rlim.rlim_cur && rlim.rlim_cur <=3D LONG_MAX)
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 = span>~ ^=C2=A0 ~~~= ~~~~~~~~~~
emacs.c:869:1= 0: warning: comparison of 0 <=3D unsigned expression is a= lways true
=C2=A0 =C2=A0 =C2=A0 [-Wtauto= logical-compare]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (0 <=3D rlim.rlim_max && rlim.rlim_max < newlim)= p>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 ~ ^= =C2=A0 ~~~~~~~~~~~~~
2 warnings gener= ated.
=
$= ./config.status --config
'= --with-modules' '--without-xml2' '--without-pop' '-= -with-mailutils' '--enable-checking' '--enable-check-lisp-o= bject-type' 'MAKEINFO=3D/usr/local/opt/texinfo/bin/makeinfo' = 39;CFLAGS=3D-ggdb3 -O0'
(i.e. this doesn't even need --enable-gcc-warnings= )
=
<= /span>The ot= her case, same repo version, but the other commit reverted:
$ make -C lib-src make= -docfile V=3D1
gcc =C2=A0 -Wno-switch -Wno-tautological-constant-out-of-range-compare -Wno-pointer-= sign -Wno-string-plus-int -Wno-unknown-attributes=C2=A0 -I. -I../src -I../lib -I. -I./../src = -I./../lib=C2=A0 =C2=A0 <= /span>-O3 -save-temps make-docfile.c=C2=A0 ../lib/libgnu.a=C2=A0 -o make-docfile
make-docfile.c:227:19: warning: equality comparison with extraneous parentheses
=C2=A0 =C2=A0 =C2=A0 [-Wparen= theses-equality]
=C2=A0 =C2= =A0 =C2=A0 if (((*tmp) =3D=3D '/'))
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ~~~~= ~~~^~~~~~
make-docfile.c:227:19: note: remove extraneous paren= theses around the comparison
= =C2=A0 =C2=A0 =C2=A0 to silence this warning
=C2=A0 =C2=A0 =C2=A0 if (((*tmp) =3D=3D '/&= #39;))
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 ~ = =C2=A0 =C2=A0 =C2=A0 ^ =C2=A0 =C2=A0 ~
make-docfile.c:227:19: note: use = '=3D' to turn this equality comparison into an
=C2=A0 =C2=A0 =C2=A0 assignment
==C2=A0 =C2=A0 =C2=A0 if (((*tmp) = =3D=3D '/'))
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^~
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D
1 war= ning generated.
$ ./config.status --config
<= span class=3D"inbox-inbox-s1">
'= --with-modules' '--without-xml2' '--without-pop' '-= -with-mailutils' '--enable-checking' '--enable-check-lisp-o= bject-type' 'MAKEINFO=3D/usr/local/opt/texinfo/bin/makeinfo' = 39;CFLAGS=3D-O3 -save-temps'
Note that the -save-temps is crucial here, withou= t it the compiler doesn't look at the preprocessed output.
It's weird tha= t -save-temps generates more warnings, but GCC has similar issues (https://gcc.gnu.o= rg/bugzilla/show_bug.cgi?id=3D57201). -save-temps also generates tons o= f warnings for other files, even without --enable-gcc-warnings.
<= p class=3D"inbox-inbox-p1">Not sure what to = do about the -save-temps problem. Maybe that's just something to docume= nt somewhere, because there seems to be little we can do about it.= p>
$ gcc --version=
Confi= gured with: --prefix=3D/Applications/Xcode.app/Contents/Developer/usr --wit= h-gxx-include-dir=3D/Applications/Xcode.app/Contents/Developer/Platforms/Ma= cOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1= p>
Apple LLVM ver= sion 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
Insta= lledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault= .xctoolchain/usr/bin