[Interest] QAtomicInt overflow / wrap-around?
markus.pointner at mooware.at
Thu May 15 00:38:46 CEST 2014
I'd like to use a QAtomicInt to generate IDs, by calling fetchAndAddOrdered(1)
to get a new ID. Sooner or later the QAtomicInt will reach INT_MAX (or whatever
the constant is). Is it ok to continue with fetchAndAddOrdered(1), or do I have
to manually reset the value to a sane minimum?
I am aware that for regular non-atomic ints, this would be undefined behaviour,
whereas unsigned ints are defined to wrap around. I would prefer the wrap-around
behaviour for my atomic value.
More information about the Interest