On Mon, 13 Aug 2012, Jakub Jelinek wrote:
On Sun, Aug 12, 2012 at 11:30:59PM +0200, Marc Glisse wrote:
+inline double_int &
+double_int::operator ++ ()
+{
+ *this + double_int_one;
*this += double_int_one;
would be less confusing.
Do you mean that *this + double_int_one; alone also works, just is
confusing? That would mean operator+ has side-effects, right?
It "works" in that it compiles. It is confusing because the addition is
dead code and thus operator++ is a nop. Sorry for my confusing euphemism,
I should have called it a bug. operator+ has no side-effects AFAICS.
Note that there are many obvious places where this operator can be used:
varasm.c: i = double_int_add (i, double_int_one);
tree-vrp.c: prod2h = double_int_add (prod2h, double_int_one);
tree-ssa-loop-niter.c: bound = double_int_add (bound, double_int_one);
tree-ssa-loop-niter.c: *nit = double_int_add (*nit, double_int_one);
tree-ssa-loop-ivopts.c: max_niter = double_int_add (max_niter,
double_int_one);
gimple-fold.c: index = double_int_add (index, double_int_one);
etc.
As a side note, I don't usually like making operator+ a member function.
It doesn't matter when there is no implicit conversion, but if we ever add
them, it will make addition non-symmetric.
--
Marc Glisse