Front page | perl.perl5.porters |
Postings from November 2016
clang -Weverything
Thread Next
From:
Andy Lester
Date:
November 18, 2016 04:41
Subject:
clang -Weverything
Message ID:
D03CA6D3-FFF6-4384-B14C-1EB9368024AC@petdance.com
I've been working on getting blead to run under clang with the -Weverything switch. My work on this is on the Weverything branch at https://github.com/petdance/perl5
What I've done is turned on -Weverything but then turned off certain warnings that we don't care about (all in cflags.SH)
+ # -Wno-unused-macros: We have tons of macros and it's OK if we don't use them.
+ # -Wno-gnu-statement-expression: Commonly used all over the codebase.
+ # -Wno-shadow: We have many common global variable names. We would have to change many local variables.
+ # -Wno-overlength-strings: Compiler limit we don't care about
+ # -Wno-disabled-macro-expansion
+ # -Wno-variadic-macros: We use them.
+ # -Wno-cast-align
+ # -Wno-extended-offsetof
+ # -Wno-c11-extensions
+ # -Wno-format-nonliteral
+ # -Wno-switch-enum: This one is not mollified by a default in the case. https://stackoverflow.com/questions/16631713/
These are just the ones I feel confident that we don't actually care about. And, there are some that I think we should discuss. Here's the top of my list (Note that the line numbers are not current in the error messages)\
# -Wunreachable-code: Should we remove breaks after croaks?
Do a `make gv.o`. The last warning will be unreachable code.
gv.c:388:13: warning: will never be executed [-Wunreachable-code]
break;
^~~~~
There's a `Perl_croak` followed by a `break`, and clang tells us that the
`break` will never be reached.
It looks like clang is adding a `-Wno-unreachable-code-break` to make
it not complain about `break` but my clang 3.4.2 doesn't handle it.
See http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20140310/101435.html
# -Wconversion
This first one is in a header file, so causes warnings in every file that uses it.
./inline.h:1384:39: warning: implicit conversion loses integer precision: 'int' to 'U16' (aka 'unsigned short') [-Wconversion]
cx->blk_u16 = (PL_in_eval & 0x7F) | ((U16)PL_op->op_type << 7);
doio.c:203:22: warning: implicit conversion loses integer precision: 'int' to 'char' [-Wconversion]
IoTYPE(io) = PerlIO_intmode2str(rawmode, &mode[ix], &writing);
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# -Wfloat-equal
We seem to do a lot of float comparisons, which is surprising. Many are
against 0, but many are not.
pp_hot.c:638:20: warning: comparing floating point with == or != is unsafe [-Wfloat-equal]
nl == (NV)(il = (IV)nl) && nr == (NV)(ir = (IV)nr)
~~ ^ ~~~~~~~~~~~~~~~~~
pp_hot.c:638:47: warning: comparing floating point with == or != is unsafe [-Wfloat-equal]
nl == (NV)(il = (IV)nl) && nr == (NV)(ir = (IV)nr)
The float comparisons is what surprised me most.
Commentary?
--
Andy Lester => www.petdance.com
Thread Next
-
clang -Weverything
by Andy Lester