Skip to content

Commit c060c57

Browse files
committed
cflags.SH: Turn off attribute_nonnull warnings
gcc emits a bunch of warnings under -Wall for functions that have declared that parameter 'n' is never going to be NULL, and then have the temerity to make sure that that is true. The problem is that we have many macros that are generalized enough to handle the case where the parameter is NULL. It just happens that sometimes they get called as well from code where it is known to be not NULL. We could write additional macros that are known to take a non-NULL parameter and don't do the test. The existing macros would be rewritten to just call the new ones after checking for non-NULL. But that would complicate our code, and a main point of compilers doing optimization is to figure out and remove impossible cases, without the programmers having to be concerned with that. Just turn off these warnings
1 parent 8dcf0c1 commit c060c57

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cflags.SH

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,20 @@ Intel*) ;; # # Is that you, Intel C++?
184184
# NOTE 3: the relative order of these options matters:
185185
# -Wextra before -Wno-long-long -Wno-declaration-after-statement
186186
#
187+
# NOTE 4: If a function has __attribute__nonnull__(n), gcc generates many
188+
# warnings for macros that have the generality to check for NULLness on
189+
# parameter n. We could write versions of those macros that eliminate
190+
# that check, but why?. It complicates our code and gains no
191+
# perceptible performance except in very hot code that the compiler
192+
# has chosen to not optimize away. So turn these off with
193+
# -Wno-nonnull-compare
194+
187195
*) warns="$pedantic \
188196
-Werror=pointer-arith \
189197
-Werror=vla \
190198
-Wextra \
191199
-Wno-long-long -Wno-declaration-after-statement \
200+
-Wno-nonnull-compare \
192201
-Wc++-compat -Wwrite-strings"
193202
case " $ccflags " in
194203
*" -std="*) ;; # Already have -std=...

0 commit comments

Comments
 (0)