Closed Bug 778984 Opened 13 years ago Closed 8 years ago

Enable clang -Werror=null-conversion on OS X

Categories

(Firefox Build System :: General, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: cpeterson, Unassigned)

References

Details

Given the following example code: char a = nullptr; int b = nullptr; char c = NULL; int d = NULL; * clangs emits these nullptr errors and NULL warnings on OS X: error: assigning to 'char' from incompatible type 'nullptr_t' error: assigning to 'int' from incompatible type 'nullptr_t' warning: implicit conversion of NULL constant to 'char' [-Wnull-conversion] Note that clang warns about implicit conversion of nullptr to int, but not NULL to int! To make clang's NULL warnings fatal like its nullptr errors, we may want to add -Werror=null-conversion to clang's CFLAGS/CXXFLAGS. For comparison, gcc 4.5 emits these warnings on Linux (which might be treated as errors by bug 778980): warning: converting to non-pointer type 'char' from NULL warning: converting to non-pointer type 'char' from NULL warning: converting to non-pointer type 'int' from NULL warning: converting to non-pointer type 'int' from NULL
Component: MFBT → Build Config
gcc 4.7 added a similar nullptr warning: -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.
Resolving this bug as WONTFIX because: 1. clang's -Wnull-conversion flag no longer actually warns about implicit conversion of NULL constant to char, which kind of defeats the purpose of this bug. I filed a clang bug upstream: https://bugs.llvm.org//show_bug.cgi?id=31842 2. Our current approach to C/C++ warnings is to not force individual warnings-as-errors with -Werror=whatever because it is unfriendly to developers with different toolchains. We enable -Werror in our automation so we will catch these warnings before the code lands in mozilla-central. Developers should --enable-warnings-as-errors in their mozconfig to catch this warnings on their local machines.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → WONTFIX
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.