On 30 Aug, Kay Schenk wrote:
>
>
> On 08/29/2016 04:14 PM, Don Lewis wrote:
>> When building OpenOffice trunk revsion r1758161 as a FreeBSD port on
>> FreeBSD 12.0-CURRENT with clang 3.8.0, I get the following warnings.
>> I'm mostly interested in the OpenOffice code and not the bundled
>> external code, so I specifically built the FreeBSD port it uses
>> --with-system-foo extensively which minimizes the compilation of third
>> party code. The total number of warnings is 5105.
>>
>> 1175 -Wtautological-undefined-compare
>> 949 -Wunused-private-field
>> 660 -Wshift-negative-value
>> 391 -Wunused-parameter
>> 362 -Wunused-const-variable
>> 312 -Woverloaded-virtual
>> 177 -Wunused-variable
>> 116 -Winfinite-recursion
>> 109 -Wlogical-op-parentheses
>> 93 -Wsign-compare
>> 76 -Wdelete-non-virtual-dtor
>> 72 -Wint-to-void-pointer-cast
>> 63 -Wshadow
>> 55 -Wunused-function
>> 41 -Wformat
>> 36 -Wreturn-type-c-linkage
>> 30 -Wchar-subscripts
>> 27 -Wdeprecated-declarations
>> 26 -Wundefined-bool-conversion
>> 26 -Wsizeof-pointer-memaccess
>> 26 -Wformat-security
>> 24 -Wunused-local-typedef
>> 22 -Wmacro-redefined
>> 21 -Wswitch
>> 20 -Wbitwise-op-parentheses
>> 18 -Winvalid-source-encoding
>> 13 -Wuninitialized
>> 11 -Wtautological-compare
>> 11 -Wlogical-not-parentheses
>> 11 -Wdangling-else
>> 9 -Wmismatched-new-delete
>> 8 -Wimplicit-function-declaration
>> 8 -Wheader-guard
>> 8 -Wcomment
>> 7 -Wtautological-constant-out-of-range-compare
>> 7 -Wself-assign
>> 6 -Wunused-value
>> 6 -Wunneeded-internal-declaration
>> 6 -Wtautological-pointer-compare
>> 6 -Wpointer-bool-conversion
>> 6 -Wparentheses-equality
>> 6 -Wdynamic-class-memaccess
>> 6 -Wconstant-conversion
>> 5 -Wpointer-sign
>> 4 -Wnull-conversion
>> 3 -Wunsequenced
>> 3 -Wreorder
>> 3 -Wknr-promoted-parameter
>> 3 -Wint-to-pointer-cast
>> 2 -Wstrncat-size
>> 2 -Wstring-compare
>> 2 -Wsometimes-uninitialized
>> 2 -Wconstant-logical-operand
>> 2 -Warray-bounds
>> 1 -Wunused-comparison
>> 1 -Wunknown-pragmas
>> 1 -Wstring-plus-int
>> 1 -Wpotentially-evaluated-expression
>> 1 -Wnon-literal-null-conversion
>> 1 -Wmismatched-tags
>> 1 -Wincompatible-pointer-types-discards-qualifiers
>> 1 -Wimplicit-int
>> 1 -Wignored-qualifiers
>> 1 -Wformat-extra-args
>> 1 -Wcompare-distinct-pointer-types
>> 1 -Wc++11-compat-deprecated-writable-strings
>>
>>
>> A couple -Wtautological-undefined-compare warnings:
>>
>> warning: reference cannot be bound to dereferenced null pointer in
>> well-defined C++ code; comparison may be assumed to always evaluate to false
>> [-Wtautologica
>> l-undefined-compare]
>> if (&other == NULL) {
>> ^~~~~ ~~~~
>
> This one is apparently an old holdoever from C and not recommended
> currently...
>
> See. e.g:
> http://stackoverflow.com/questions/17772103/can-i-use-if-pointer-instead-of-if-pointer-null
>
> It probably needs an update to accomplish what it's trying to do.
>
>
>>
>> warning: 'this' pointer cannot be null in well-defined C++ code; comparison
>> may be assumed to always evaluate to false [-Wtautological-undefin
>> ed-compare]
>> if(this == 0 || this == &src) {
>> ^~~~ ~
>>
>
> Same here...
nullptr is a c++11 thing and is not supported by older compilers.
When I upgraded one of the bundled packages (nss?) I found it had some
test code that used nullptr that didn't compille on many of our
platforms. I had to disconnect the tests from the build.
The warnings are about things that can't be null. In the first case if
you have a reference to another variable, then the address of that
variable can't be null. In the second case, this could only be null if
you call a method on a null object.
One of the bits of code that I looked at for the first error looked
suspicious. It looks like it is passing *ptr as a reference parameter.
I'm not sure that's legal, and then the question is what happens if ptr
is null? Other calls to the same function were passing a regular
variable by reference. The appropriate fix in this case my be to create
a variant function that accepts a pointer and checks for NULL. Rather
than checking &ref == NULL.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]