Closed Bug 777515 Opened 8 years ago Closed 6 years ago
Enable gcc -Wzero-as-null-pointer-constant warnings for gcc >= 4
gcc 4.7 added a new command-line option -Wzero-as-null-pointer-constant to warn when a literal '0' is used as null pointer constant. It can be useful to facilitate the conversion to nullptr in C++11. http://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Warning-Options.html -Wzero-as-null-pointer-constant (C++ and Objective-C++ only) Warn when a literal '0' is used as null pointer constant. This can be useful to facilitate the conversion to nullptr in C++11.
I vote that in the absence of tree-wide FAIL_ON_WARNINGS, the switch be -Werror=zero-as-null-pointer-constant unconditionally, so that we're not fixing warnings that should have been errors.
Try doesn't run gcc 2.7 yet, does it? So making this fatal (even in directories that opt in to fatal warnings generally) would just break the build for anyone using gcc 2.7. Until we have at least tryservers running gcc 2.7, we need to use -Wnoerror for it even with FAIL_ON_WARNINGS.
(In reply to :Aryeh Gregor from comment #2) > Try doesn't run gcc 2.7 yet, does it? So making this fatal (even in > directories that opt in to fatal warnings generally) would just break the > build for anyone using gcc 2.7. Until we have at least tryservers running > gcc 2.7, we need to use -Wnoerror for it even with FAIL_ON_WARNINGS. I dunno, even our current FAIL_ON_WARNINGS directories have broken things for people using GCC 4.6, and we don't have 4.6 on try. Maybe it's not a big deal either way.
Well, it might be tenable, but only if someone fixes up the whole tree first. I can guarantee you, based on converting nsnull to nullptr and now nsresult to an enum, that there will be hundreds of places where people use things that happen to equal zero instead of null pointer values, because the compiler will accept it.
Sounds like we should just enable the warning for now, and hold off to making it fatal until our official builds are on GCC 4.7 or newer.
Firefox for Android is now compiled using gcc 4.7. However, gcc -Wzero-as-null-pointer-constant generates thousands (or tens of thousands if you count warnings from header files like nsCOMPtr and that gcc -Wzero-as-null-pointer-constant warns about using NULL, not just 0). AFAICT none of them are bugs, just style warnings.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.