r/cpp • u/nukethebees • Jun 29 '26
Comparing an Integer Division Optimisation in Clang, MSVC, and GCC
https://nukethebees.com/int-division-modulo-optimisation-differences-clang-gcc-msvc/
56
Upvotes
View all comments
Show parent comment
22
u/BarryRevzin Jun 30 '26
The other fun thing about
std::divis that the declaration order of the members is unspecified.So not only is this not inlined (so this is a function call that does a full division, not a shift):
But also there's no guarantee that
quotis the quotient.Like I said... fun.