develooper Front page | perl.perl5.porters | Postings from November 2016

clang -Weverything

Thread Next
Andy Lester
November 18, 2016 04:41
clang -Weverything
Message ID:
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

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.

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]

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.


# -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.


Andy Lester =>

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About