Kay Ramme - Sun Germany - Hamburg wrote:
Stephan Bergmann wrote:
Kay Ramme - Sun Germany - Hamburg wrote:
Hi,
please correct me, if I am wrong. I understand this as a 'C'
inherited C++ oddity (no constructors for integral values), which
leads to a warning if the first operation on the integral value is
not classified as "assignment". Obviously 'operator >>=' has not been
classified as "assignment" at least not for the right operand.
No, the compiler does not assume the user-supplied operator >>= has
any assignment semantics. Rather, as the operator >>= is inline, GCC
tries
I thought that this is what I said ;-), however.
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.
Certainly not in general, only for the places the warning gets emitted.
And only for the reason, that we may have chosen the wrong operator.
I do not understand why the choice of function name should motivate us
to change or not to change some code so that the (imperfect)
definitive-assignment-analysis of some compiler does not cause problems.
(The chosen function name "operator >>=" is IMO unfortunate in that a
human reader might assume modification of the lhs, whereas it actually
does assignment to the rhs.)
If I get it right, the compiler makers are more or less in a dilemma.
Why? They just need to be conservative in
definitive-assignment-analysis and do not emit warnings if the compiler
is not sure that a variable has definitely not been assigned a value (as
most compiler versions seem to do).
-Stephan
-Stephan
Kay
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]