Douglas Gregor wrote:
> Author: dgregor
> Date: Wed Dec 10 17:01:14 2008
> New Revision: 60858
>
> URL: http://llvm.org/viewvc/llvm-project?rev=60858&view=rev
> Log:
> Added a warning when referencing an if's condition variable in the
> "else" clause, e.g.,
>
>   if (int X = foo()) {
>   } else {
>     if (X) { // warning: X is always zero in this context
>     }
>   }
>   
What happens for

struct WithToBool
{
  operator bool() { ... }

  // Other data, not necessarily invalid if (bool)WTB is false.
};

if(WithToBool wtb = something()) {
} else {
  orother(wtb);
}

It seems to me, from looking at the code (not trying it) that this will 
warn about wtb always being zero.

Sebastian

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to