Frank Schönheit - Sun Microsystems Germany wrote:
Hi Stephan,

So, it seems that we have used the wrong operator here. Therefor I tend to agree to Frank, that we may want to fix this.
The choice of operator is indeed unfortunate.  However, I do not agree that

   - T b;
   + T b = T();

is in general a fix that improves code quality.

Don't know which Ts are affected, but the original example was about
sal_Bool, and

  - sal_Bool b;
  + sal_Bool b( sal_False );

seems legitimate to me.

With GCC 4.0.2, sal_Bool and other "small" integral types like sal_Int16, sal_Unicode are affected. With GCC 4.1.1, only those other "small" integral types are affected (which are used considerably less often in conjunction with com::sun::star::Any than sal_Bool).

In the case of sal_Bool, it might be true that false is a better default value than true (no pun intended), but that need not be the case always, so you would have to analyze each place in the code where you add "= false", which is tedious due to the large number of places involved. And still, I personally consider it a degradation of code quality to explicitly assign an (arbitrary) default value to a variable in places where it is obvious that the variable is only used after definitively having been assigned to (in places where that is not obvious, I think it is often better to restructure the code to make that obvious, than to initially assign an arbitrary dummy value to the variable; rationale: in the latter case, the reader has to scan the code to find out whether the initial assignment is of importance, or merely there to silence warnings from the compiler).

Besides that: Sure, not every change we did during the warning-freeness
ride does directly improve code quality. But this is not the point -
it's getting the code to compile without warning :)

...but only on compilers where we can achieve this with a reasonable amount of work. If we would need to make lots of "hacky" changes to make a single version of GCC work, while most other versions (even more recent ones) of GCC would not need that, I think we should weigh what is more important. That's all I wanted to say.

There will probably always be warnings which are wrong. Remember for
instance MSVC's
  Foo* pFoo = ...;
  pFoo->doSomething();
which sometimes yields the wrong "pFoo might be used without being
initialized" (or so) warning.
In those cases, we simply need to workaround the compiler bug/limitation
here.

Of course, if there are other alternatives (other than disabling the
respective warning completely), then that's fine, too. However, none
springs to my mind ...

Not supporting GCC 4.0.2 is the alternative that springs to my mind (see above).

-Stephan

Ciao
Frank

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to