Skip to content

Get rid of compiler warnings #392

@plexoos

Description

@plexoos

Our build system currently asks the compiler to print many useful warnings (-Wall). This sounds like a good idea since warnings may indicate problematic places in the code, obsolete features, or the use of nonstandard extension of C/C++. However, it appears that the reported warnings have been ignored for quite a long time. Currently there are about 3,000 warnings reported by gcc 4.8.5. A goal to address all the warnings should be recognized and a zero-warning policy should be enforced for all future code modifications.

A list of warnings sorted by their frequency in the build log (gcc 4.8.5, root 5):

                                                                      msg  count   freq
0         deprecated conversion from string constant to [-Wwrite-strings]    798  27.0%
1      may be used uninitialized in this function [-Wmaybe-uninitialized]    435  14.7%
2   deleting object of polymorphic class type which has non-virtual de...    403  13.6%
3                   variable set but not used [-Wunused-but-set-variable]    341  11.5%
4                                     unused variable [-Wunused-variable]    293   9.9%
5      format expects argument of type, but argument has type [-Wformat=]    210   7.1%
6   comparison between signed and unsigned integer expressions [-Wsign...     73   2.5%
7   iteration invokes undefined behavior [-Waggressive-loop-optimizati...     56   1.9%
8                        operation on may be undefined [-Wsequence-point]     54   1.8%
9                           declaration of shadows a member of [-Wshadow]     41   1.4%
10           converting to non-pointer type from NULL [-Wconversion-null]     30   1.0%
11                                  unused parameter [-Wunused-parameter]     25   0.8%
12                       ignoring #pragma omp section [-Wunknown-pragmas]     22   0.7%
13                                      was hidden [-Woverloaded-virtual]     20   0.7%
14                 array subscript is above array bounds [-Warray-bounds]     14   0.5%
15  dereferencing type-punned pointer will break strict-aliasing rules...     13   0.4%
16                               defined but not used [-Wunused-variable]     12   0.4%
17                                  will be initialized after [-Wreorder]     11   0.4%
18                               defined but not used [-Wunused-function]      9   0.3%
19                unknown conversion type character in format [-Wformat=]      8   0.3%
20               control reaches end of non-void function [-Wreturn-type]      7   0.2%
21  argument to in call is the same pointer type as the destination; e...      7   0.2%
22                    too many arguments for format [-Wformat-extra-args]      7   0.2%
23  type qualifiers ignored on function return type [-Wignored-qualifi...      6   0.2%
24                            value computed is not used [-Wunused-value]      6   0.2%
25             suggest explicit braces to avoid ambiguous [-Wparentheses]      6   0.2%
26                               statement has no effect [-Wunused-value]      5   0.2%
27                                             within comment [-Wcomment]      5   0.2%
28  base class should be explicitly initialized in the copy constructo...      4   0.1%
29  comparison with string literal results in unspecified behaviour [-...      4   0.1%
30  cast to pointer from integer of different size [-Wint-to-pointer-c...      4   0.1%
31                      suggest parentheses around within [-Wparentheses]      3   0.1%
32                     the address of will always evaluate as [-Waddress]      3   0.1%
33    suggest parentheses around comparison in operand of [-Wparentheses]      3   0.1%
34           extra tokens at end of #endif directive [enabled by default]      2   0.1%
35       large integer implicitly truncated to unsigned type [-Woverflow]      2   0.1%
36         typedef locally defined but not used [-Wunused-local-typedefs]      2   0.1%
37                                         redefined [enabled by default]      2   0.1%
38                                    repeated flag in format [-Wformat=]      2   0.1%
39  argument to in call is the same expression as the destination; did...      2   0.1%
40                      ignoring #pragma omp parallel [-Wunknown-pragmas]      2   0.1%
41     no return statement in function returning non-void [-Wreturn-type]      2   0.1%
42                 use of length modifier with type character [-Wformat=]      1   0.0%
43                          initialized and declared [enabled by default]      1   0.0%
44  field precision specifier expects argument of type, but argument h...      1   0.0%
45            zero-length gnu_printf format string [-Wformat-zero-length]      1   0.0%
46                         format expects a matching argument [-Wformat=]      1   0.0%
47                            label defined but not used [-Wunused-label]      1   0.0%

fix_warns_orig

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions