On Thu, 2011-11-24 at 07:50 +0100, Lionel Elie Mamane wrote: > On Wed, Nov 23, 2011 at 06:53:53PM -0500, Kohei Yoshida wrote: > > > I'd like to have > > > http://cgit.freedesktop.org/libreoffice/core/commit/?id=0215f8b19451ab67c7fdaf91f2da8298a9b89c47 > > > cherry-picked to the 3-4 branch. It fixes > > > https://bugs.freedesktop.org/show_bug.cgi?id=39589 > > I see how ulimit_cast is the wrong choice there, but: > > If I understand well, static_cast<unsigned int>(a) where a is a signed > int returns a+2^n where n is the length of int in bits. > > For example, for 32 bit ints, static_cast<unsigned int>(-1) is > 2^32-1. > > Why is that the best solution, rather than 0, which as far as I > understand, limit_cast<unsigned int>(a) would use?
Both are 32-bit integers. We are casting long to unsigned long. And since the original value is a cell position, it is never negative. Plus, I don't like those "smart" casters which apparently do wrong things sometimes and IMO bit unclear how they are supposed to be used, and apparently with hidden gotchas. Also, I never said it was the best solution. Rather, it's better than the current (which "casts" 0 to -1 or 0xFFFFFFFF). To me, that's enough of an argument but other people may disagree. *shrug* Kohei -- Kohei Yoshida, LibreOffice hacker, Calc _______________________________________________ LibreOffice mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice
