> When multiplying variables, the overflow will take place anyway, and only > then will the meaningless product be explicitly promoted to type int64. > It is one of the operands that should have been cast instead to avoid the > overflow. > > - if (state->availMem < (int64) ((newmemtupsize - memtupsize) * sizeof(SortTuple))) > + if (state->availMem < ((int64) (newmemtupsize - memtupsize) * sizeof(SortTuple)))
Doesn't sizeof() return a 64-bit wide value already?
Sizeof return size_t.
Both versions are constant expressions of type std::size_t.