xref: /netbsd-src/external/gpl3/gcc.old/README.warnings (revision 23f5f46327e37e7811da3520f4bb933f9489322f)
1$NetBSD: README.warnings,v 1.5 2023/07/14 19:46:25 mrg Exp $
2
3What to do about GCC warnings and NetBSD.
4
5
6New GCC releases always come with a host of new warnings and
7each new warning can find real bugs, find odd code, or simply
8be a pain of new useless warnings, or all three and more.
9
10As each warning has its own set of issues they each have their
11own section and it is expected that this document will be
12modified for updates to warnings and new warnings.
13
14
15<bsd.own.mk> provides several variables for use in Makefiles:
16   COPTS.foo.c += ${CC_WNO_FORMAT_TRUNCATION}
17   COPTS.foo.c += ${CC_WNO_FORMAT_OVERFLOW}
18   COPTS.foo.c += ${CC_WNO_STRINGOP_OVERFLOW}
19   COPTS.foo.c += ${CC_WNO_STRINGOP_TRUNCATION}
20   COPTS.foo.c += ${CC_WNO_CAST_FUNCTION_TYPE}
21   COPTS.foo.c += ${CC_WNO_IMPLICIT_FALLTHROUGH}
22   COPTS.foo.c += ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}
23   COPTS.foo.c += ${CC_WNO_MAYBE_UNINITIALIZED}
24   COPTS.foo.c += ${CC_WNO_RETURN_LOCAL_ADDR}
25
26
27new GCC 10 warnings:
28
29  GCC 10 switched the default from "-fcommon" to "-fno-common",
30  which can cause multiply defined symbol issues.  Ideally we
31  fix all of these, but "-fcommon" can be used otherwise.
32
33  -Wno-maybe-uninitialized
34
35      This warning was introduced in an ancient GCC but was
36      significantly enhanced in GCC 10, unfortunately, many of
37      the new instances are incorrect.
38
39      bsd.own.mk variable: ${CC_WNO_MAYBE_UNINITIALIZED}
40
41  -Wno-return-local-addr
42
43      This warning was introduced in GCC 5 and was enhanced in GCC
44      10.  Unfortunately, the new instances are failing to correctly
45      analyze code flow and miss that most of the are handled.
46
47      bsd.own.mk variable: ${CC_WNO_RETURN_LOCAL_ADDR}
48
49
50new GCC 9 warnings:
51
52  -Wno-address-of-packed-member
53
54      This warning was introduced in GCC 8.
55      This warning is similar to -Wformat-truncation, but for the
56      general family of string functions (str*(), etc.), and has
57      similar issues of false positives.
58
59      bsd.own.mk variable: ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}
60
61
62new GCC 8 warnings:
63
64  -Wstringop-truncation
65
66      This warning was introduced in GCC 8.
67      This warning is similar to -Wformat-truncation, but for the
68      general family of string functions (str*(), etc.), and has
69      similar issues of false positives.
70
71      bsd.own.mk variable: ${CC_WNO_STRINGOP_TRUNCATION}
72
73
74  -Wcast-function-type
75
76      This warning was introduced in GCC 8.
77      This warning can find real problems.  Most instances are
78      false positives, and hopefully this warning will become
79      more useful in the future.  See __FPTRCAST().
80
81      bsd.own.mk variable: ${CC_WNO_CAST_FUNCTION_TYPE}
82
83
84new GCC 7 warnings:
85
86  -Wstringop-overflow
87
88      This warning was introduced in GCC 7.
89      This warning can find issues where source length is
90      passed as destination length (eg, strncpy() where the
91      length is strlen(src)) that are potential buffer overflow
92      cases and should always be inspected, but false positives
93      are also seen.
94
95      bsd.own.mk variable: ${CC_WNO_STRINGOP_OVERFLOW}
96
97
98  -Wformat-truncation
99
100    This warning was introduced in GCC 7.
101    This warning has many false positives where truncation is
102    either expected or unavoidable, but also finds several real
103    code bugs.
104
105    Code should always be manually inspected for this warning
106    as it does pick up real issues.
107
108    bsd.own.mk variable: ${CC_WNO_FORMAT_TRUNCATION}
109
110
111  -Wformat-overflow
112
113    This warning was introduced in GCC 7.
114    This warning typically identifies a real problem, but it may
115    fail to notice the code handles this case.
116
117    Code should always be manually inspected for this warning
118    as it does pick up real issues.
119
120    bsd.own.mk variable: ${CC_WNO_FORMAT_OVERFLOW}
121
122
123  -Wimplicit-fallthrough
124
125    This warning was introduced in GCC 7.
126    This warning has many false positives in GCC 7, and many are
127    fixed in newer GCC 10.  Old uses should be checked occasionally.
128
129    Code should always be manually inspected for this warning
130    as it does pick up real issues.
131
132    bsd.own.mk variable: ${CC_WNO_IMPLICIT_FALLTHROUGH}
133