Matthieu Fertré a écrit : > I'm quite fed up with integer overflow/wrap. Unsigned integers in > particular are particularly dangerous [1]. Last week, I have again fixed > a bug related to unsigned int wrap (uint length = 0 - 4, the result of > this operation gives a very big number, not zero nor -4) > > One friend suggests me to implement an UnsignedInt class, redefining > operators, so that it ensures that unsigned never begans negative and > launches assertion failure when it happens. Then, we just have to > "typedef uint UnsignedInt" instead of "typedef uint unsigned int". > > Are you ok with that ? (The class may optionnally be used only in debug > mode)
Uh... wouldn't it be simpler to enable some compiler warnings on stupid integer arithmetic, and fix those places which trigger those? I fear a class for unsigned integers will use more memory and be slower... Snark _______________________________________________ Wormux-dev mailing list Wormux-dev@gna.org https://mail.gna.org/listinfo/wormux-dev