Re: compiler warnings when building OpenOffice

2016-09-06 Thread Don Lewis
On  1 Sep, Don Lewis wrote:

>  493 -Wunused-private-field
>  391 -Wunused-parameter
>  366 -Wunused-const-variable
>  314 -Woverloaded-virtual
>  181 -Wunused-variable
>  109 -Wlogical-op-parentheses
>   93 -Wsign-compare
>   77 -Wdelete-non-virtual-dtor
>   72 -Wint-to-void-pointer-cast
>   63 -Wshadow
>   56 -Wunused-function
>   41 -Wformat
>   36 -Wreturn-type-c-linkage
>   30 -Wchar-subscripts
>   27 -Wdeprecated-declarations
>   26 -Wundefined-bool-conversion
>   26 -Wsizeof-pointer-memaccess
>   25 -Wtautological-undefined-compare
>   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 -Wcomment
>7 -Wtautological-constant-out-of-range-compare
>7 -Wself-assign
>7 -Wheader-guard
>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


Here is the per-module warning count:
 513 icc
 222 sw
 167 svx
 154 icu
 151 oox
 149 sc
 145 sd
 107 svtools
  72 vcl
  70 sal
  67 xmloff
  52 i18npool
  46 cui
  42 sfx2
  40 connectivity
  39 dbaccess
  38 canvas
  36 slideshow
  34 sdext
  31 filter
  29 xmlhelp
  29 libxmlsec
  29 chart2
  28 framework
  27 toolkit
  25 editeng
  25 accessibility
  24 reportdesign
  22 l10ntools
  20 basic
  20 basegfx
  19 desktop
  19 automation
  14 xmlsecurity
  14 avmedia
  12 ucb
  11 extensions
  11 cppuhelper
  10 writerfilter
  10 unoxml
   9 starmath
   9 basctl
   7 tools
   7 soltools


-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
For additional commands, e-mail: dev-h...@openoffice.apache.org



Re: compiler warnings when building OpenOffice

2016-09-04 Thread Patricia Shanahan

On 9/4/2016 3:45 PM, Patricia Shanahan wrote:

On 9/1/2016 4:00 PM, Don Lewis wrote:

On  1 Sep, Patricia Shanahan wrote:

I need a problem to work on. Would you like me to take a particular
compiler warning and try to sort it out?


Here is one:

/wrkdirs/usr/ports/editors/openoffice-devel2/work/aoo-4.2.0/main/solver/420/unxfbsdx.pro/inc/osl/diagnose.hxx:65:25:
warning: 'osl_detail_ObjectRegistry_getMutex' has C-linkage specified,
but returns user-defined type '::osl::Mutex &' which is incompatible
with C [-Wreturn-type-c-linkage]

In sal/inc/osl/diagnose.hxx,
  ::osl::Mutex & SAL_CALL osl_detail_ObjectRegistry_getMutex()
is declared inside an extern "C" block, so it should have C linkage, but
it is returning a reference, which is a C++ thing.

The obvious fix would seem to be to move it out of the extern "C" block,
but I don't know what to do about the SAL_THROW_EXTERN_C() part of the
declaration.


I have compiled and done some basic tests with the declaration simply
moved out of the extern "C" block, and it did not appear to cause any
problems. I'll look into SAL_THROW_EXTERN_C next.


SAL_THROW_EXTERN_C and SAL_THROW are concerned with generating, or not 
generating, a dynamic exception specification in a function declaration. 
According to Wikipedia, 
https://en.wikipedia.org/wiki/C%2B%2B11#Features_removed_or_deprecated, 
dynamic exception specifications have been deprecated since C++11.


SAL_THROW_EXTERN_C with __cplusplus defined generates "throw ()", 
regardless of the linkage.


My recommendation is to leave it unchanged, but at some point we should 
examine and reconsider both SAL_THROW macros.


They are declared in main/sal/inc/sal/types.h

-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
For additional commands, e-mail: dev-h...@openoffice.apache.org



Re: compiler warnings when building OpenOffice

2016-09-04 Thread Patricia Shanahan

On 9/1/2016 4:00 PM, Don Lewis wrote:

On  1 Sep, Patricia Shanahan wrote:

I need a problem to work on. Would you like me to take a particular
compiler warning and try to sort it out?


Here is one:

/wrkdirs/usr/ports/editors/openoffice-devel2/work/aoo-4.2.0/main/solver/420/unxfbsdx.pro/inc/osl/diagnose.hxx:65:25:
 warning: 'osl_detail_ObjectRegistry_getMutex' has C-linkage specified, but returns 
user-defined type '::osl::Mutex &' which is incompatible with C 
[-Wreturn-type-c-linkage]

In sal/inc/osl/diagnose.hxx,
  ::osl::Mutex & SAL_CALL osl_detail_ObjectRegistry_getMutex()
is declared inside an extern "C" block, so it should have C linkage, but
it is returning a reference, which is a C++ thing.

The obvious fix would seem to be to move it out of the extern "C" block,
but I don't know what to do about the SAL_THROW_EXTERN_C() part of the
declaration.


I have compiled and done some basic tests with the declaration simply 
moved out of the extern "C" block, and it did not appear to cause any 
problems. I'll look into SAL_THROW_EXTERN_C next.


-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
For additional commands, e-mail: dev-h...@openoffice.apache.org



Re: compiler warnings when building OpenOffice

2016-09-01 Thread Don Lewis
On  1 Sep, To: Don Lewis wrote:

> One of the -Wunused-parameter warnings led me to this questionable bit
> of code in filter/source/xsltfilter/containerhelper.hxx:
> 
> template
> inline void forEachMem(FuncType pFunc, ParamType aParam) const
> {
> forEach( ::boost::bind(pFunc, _1, aParam));
> }
> 
> template
> inline void forEachMem(FuncType pFunc, ParamType1 aParam1, ParamType2 
> aParam2) const
> {
> forEach( ::boost::bind(pFunc, -1, aParam1, aParam2 ));
> }
>  
> template typename ParamType3>
> inline void forEachMem( FuncType pFunc, ParamType1 aParam1, 
> ParamType2 aParam2, ParamType3 aParam3 ) const
> {
> forEach( ::boost::bind(pFunc, _1, aParam2, aParam2, aParam3 
> ));
> }
> 
> In the three parameter version of this code, it looks like aParam1
> should be used instead of using aParam2 twice.  Also, in the two
> parameter version of the code, it looks like _1 should be used instead
> of -1.  I haven't had a chance to investigate the possible symptoms of
> these errors or how to text the appropriate fix.

The answer is that the code in question does not appear to be used. Only
the version that doesn't take any parameters (not shown above) is used
in the filter module.

There are also copies of this code in the oox module that appear to be
correct.


-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
For additional commands, e-mail: dev-h...@openoffice.apache.org



Re: compiler warnings when building OpenOffice

2016-09-01 Thread Don Lewis
On  1 Sep, Patricia Shanahan wrote:
> I need a problem to work on. Would you like me to take a particular 
> compiler warning and try to sort it out?

Here is one:

/wrkdirs/usr/ports/editors/openoffice-devel2/work/aoo-4.2.0/main/solver/420/unxfbsdx.pro/inc/osl/diagnose.hxx:65:25:
 warning: 'osl_detail_ObjectRegistry_getMutex' has C-linkage specified, but 
returns user-defined type '::osl::Mutex &' which is incompatible with C 
[-Wreturn-type-c-linkage]

In sal/inc/osl/diagnose.hxx,
  ::osl::Mutex & SAL_CALL osl_detail_ObjectRegistry_getMutex()
is declared inside an extern "C" block, so it should have C linkage, but
it is returning a reference, which is a C++ thing.

The obvious fix would seem to be to move it out of the extern "C" block,
but I don't know what to do about the SAL_THROW_EXTERN_C() part of the
declaration.


Another one is -Woverloaded-virtual which has a number of instances.
These are the top three in terms of warning count (due to repeats):

main/solver/420/unxfbsdx.pro/inc/cppuhelper/compbase4.hxx:75:31: warning: 
'cppu::WeakComponentImplHelper4::addEventListener' hides overloaded virtual 
function [-Woverloaded-virtual]

main/solver/420/unxfbsdx.pro/inc/cppuhelper/compbase4.hxx:77:31: warning: 
'cppu::WeakComponentImplHelper4::removeEventListener' hides overloaded 
virtual function [-Woverloaded-virtual]

main/solver/420/unxfbsdx.pro/inc/canvas/base/graphicdevicebase.hxx:145:31: 
warning: 
'canvas::GraphicDeviceBase >, 
vclcanvas::SpriteDeviceHelper, vclcanvas::tools::LocalGuard, 
cppu::OWeakObject>::disposing' hides overloaded virtual function 
[-Woverloaded-virtual]

I'm not sure if there is really a problem here or if the warning is
harmless.


-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
For additional commands, e-mail: dev-h...@openoffice.apache.org



Re: compiler warnings when building OpenOffice

2016-09-01 Thread Patricia Shanahan
I need a problem to work on. Would you like me to take a particular 
compiler warning and try to sort it out?


On 9/1/2016 3:29 PM, Don Lewis wrote:

On 29 Aug, 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


Now down to 2708 warnings.  It'll be slower going from this point
forward because each of the remaining issues will have a much smaller
impact on the warning count that many of the ones I have already fixed.

FWIW, bundled icc is getting to be a significant contributer to the
remaining warnings.

One of the -Wunused-parameter warnings led me to this questionable bit
of code in filter/source/xsltfilter/containerhelper.hxx:

template
inline void forEachMem(FuncType pFunc, ParamType aParam) const
{
forEach( ::boost::bind(pFunc, _1, aParam));
}

template
inline void forEachMem(FuncType pFunc, ParamType1 aParam1, ParamType2 
aParam2) const
{
forEach( ::boost::bind(pFunc, -1, aParam1, aParam2 ));
}

template
inline void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 
aParam2, ParamType3 aParam3 ) const
{
forEach( ::boost::bind(pFunc, _1, aParam2, aParam2, aParam3 ));
}

In the three parameter version of this code, it looks like aParam1
should be used instead of using aParam2 twice.  Also, in the two
parameter version of the code, it looks like _1 should be used instead
of -1.  I haven't had a chance to investigate the possible symptoms of
these errors or how to text the appropriate fix.

 493 -Wunused-private-field
 391 -Wunused-parameter
 366 -Wunused-const-variable
 314 -Woverloaded-virtual
 181 -Wunused-variable
 109 -Wlogical-op-parentheses
  93 -Wsign-compare
  77 -Wdelete-non-virtual-dtor
  72 -Wint-to-void-pointer-cast
  63 -Wshadow
  56 -Wunused-function
  41 -Wformat
  36 -Wreturn-type-c-linkage
  30 -Wchar-subscripts
  27 -Wdeprecated-declarations
  26 -Wundefined-bool-conversion
  26 -Wsizeof-pointer-memaccess
  25 -Wtautological-undefined-compare
  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 -Wcomment
   7 -Wtautological-constant-out-of-range-compare
   7 -Wself-assign
   7 -Wheader-guard
   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
   

Re: compiler warnings when building OpenOffice

2016-09-01 Thread Don Lewis
On 29 Aug, 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

Now down to 2708 warnings.  It'll be slower going from this point
forward because each of the remaining issues will have a much smaller
impact on the warning count that many of the ones I have already fixed.

FWIW, bundled icc is getting to be a significant contributer to the
remaining warnings.

One of the -Wunused-parameter warnings led me to this questionable bit
of code in filter/source/xsltfilter/containerhelper.hxx:

template
inline void forEachMem(FuncType pFunc, ParamType aParam) const
{
forEach( ::boost::bind(pFunc, _1, aParam));
}

template
inline void forEachMem(FuncType pFunc, ParamType1 aParam1, ParamType2 
aParam2) const
{
forEach( ::boost::bind(pFunc, -1, aParam1, aParam2 ));
}
 
template
inline void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 
aParam2, ParamType3 aParam3 ) const
{
forEach( ::boost::bind(pFunc, _1, aParam2, aParam2, aParam3 ));
}

In the three parameter version of this code, it looks like aParam1
should be used instead of using aParam2 twice.  Also, in the two
parameter version of the code, it looks like _1 should be used instead
of -1.  I haven't had a chance to investigate the possible symptoms of
these errors or how to text the appropriate fix.

 493 -Wunused-private-field
 391 -Wunused-parameter
 366 -Wunused-const-variable
 314 -Woverloaded-virtual
 181 -Wunused-variable
 109 -Wlogical-op-parentheses
  93 -Wsign-compare
  77 -Wdelete-non-virtual-dtor
  72 -Wint-to-void-pointer-cast
  63 -Wshadow
  56 -Wunused-function
  41 -Wformat
  36 -Wreturn-type-c-linkage
  30 -Wchar-subscripts
  27 -Wdeprecated-declarations
  26 -Wundefined-bool-conversion
  26 -Wsizeof-pointer-memaccess
  25 -Wtautological-undefined-compare
  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 -Wcomment
   7 -Wtautological-constant-out-of-range-compare
   7 -Wself-assign
   7 -Wheader-guard
   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 

Re: compiler warnings when building OpenOffice

2016-08-30 Thread Don Lewis
On 30 Aug, Don Lewis wrote:
> On 30 Aug, Kay Schenk wrote:
>> 
>> 
>> On 08/29/2016 04:14 PM, Don Lewis wrote:

>>> 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 ( == 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 == ) {
>>>  ^~~~~
>>> 
>> 
>> 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  == NULL.

Hmn, this is what I was afraid of.  The following code compiles without
any warnings or errors:

#include 
 
void 
func(int )
{
fprintf(stderr, "%p\n", );
}
 
int 
main(void)
{
int i, *p1, *p2;

i = 42;
p1 = 
p2 = NULL;
 
func(*p1);
func(*p2);
}

Running it gives the following output:

0x7fffea7c
0x0

So basically it is allowing *p2 to be dereferenced even though it is
NULL, and the address of the reference variable inside func() is 0.

I guess this isn't well defined C++ code ...




-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
For additional commands, e-mail: dev-h...@openoffice.apache.org



Re: compiler warnings when building OpenOffice

2016-08-30 Thread Don Lewis
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 ( == 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 == ) {
>>  ^~~~~
>> 
> 
> 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  == NULL.



-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
For additional commands, e-mail: dev-h...@openoffice.apache.org



Re: compiler warnings when building OpenOffice

2016-08-30 Thread Kay Schenk


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 ( == 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 == ) {
>  ^~~~~
> 

Same here...

> I'd like to just nuke these comparisions.
> 
> 
> To fix the -Wunused-private-field private field warnings, I'd prefer to
> delete them, but that would have the side effect of breaking the ABI if
> an extensions use the class constructor.  The alternative would be to
> mark them unused.  I don't think there are actually many cases of this.
> The same warning gets generated anytime the header is included.
> 
> 
> In the case of -Wshift-negative-value, result of shifting negative
> values is undefined.  This is generally fixable by using unsigned values
> instead.
> 
> 
> I'm not sure what to about -Wunused-parameter.  It's probably a case by
> case situation where it may sometimes make sense to have a variant
> function that doesn't have that parameter and modify the callers.  The
> alternative is to mark the argument as unused.  I haven't really
> examined any of these in detail.
> 
> 
> For -Wunused-const-variable and -Wunused-variable, I propose just
> deleting them unless they are referenced by conditionally compiled code,
> in which case I would make the variable declaration conditional as well.
> 
> 
> I fixed one other case of -Winfinite-recursion.  I'm pretty sure this is
> just one error, but it is contained in a header.
> 
> 
> I think -Wshadow warnings should be fixed by renaming the variable.
> 
> 
> I don't recall ever seeing -Wunused-function scroll by, but if functions
> are totally unused, they should be deleted.
> 
> 
> The parentheses warnings should just get fixed.
> 
> 
> This is an example -Wdelete-non-virtual-dtor warning:
> 
> warning: delete called on non-final 'RscError' that has virtual functions but 
> non-virtual destructor [-Wdelete-non-virtual-dtor]
> delete pErrHdl;
> 
> My C++ book says that non-virtual destructors are bad generally bad.  We
> also compile 

Re: compiler warnings when building OpenOffice

2016-08-29 Thread Don Lewis
On 29 Aug, 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 ( == NULL) {
>  ^
> 
> 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 == ) {
>  ^~~~~
> 
> I'd like to just nuke these comparisions.

It looks like all the noise actually just stems from 26 instances of the
first of these and three of the second.


> To fix the -Wunused-private-field private field warnings, I'd prefer to
> delete them, but that would have the side effect of breaking the ABI if
> an extensions use the class constructor.  The alternative would be to
> mark them unused.  I don't think there are actually many cases of this.
> The same warning gets generated anytime the header is included.

There seem to be a lot more of these than I expected.

> In the case of -Wshift-negative-value, result of shifting negative
> values is undefined.  This is generally fixable by using unsigned values
> instead.
> 
> 
> I'm not sure what to about -Wunused-parameter.  It's probably a case by
> case situation where it may sometimes make sense to have a variant
> function that doesn't have that parameter and modify the callers.  The
> alternative is to mark the argument as unused.  I haven't really
> examined any of these in detail.

I've seen a mixture of causes.  Some are due to conditional
compiliation, some are class methods where the parameter is only
sometimes used.



-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
For additional commands, e-mail: dev-h...@openoffice.apache.org