Closed tcbrindle closed 8 months ago
As noted when @isaacy2012 was adding cartesian_power, the current implementation of size() for cartesian_product[_map] uses built-in multiplication in a fold expression, and could easily overflow:
cartesian_power
size()
cartesian_product[_map]
https://github.com/tcbrindle/flux/blob/85b016eee0893b4971faaa3dbb415d308212a276/include/flux/op/cartesian_base.hpp#L219-L227
It should use num::checked_mul() instead to guard against UB.
num::checked_mul()
As noted when @isaacy2012 was adding
cartesian_power
, the current implementation ofsize()
forcartesian_product[_map]
uses built-in multiplication in a fold expression, and could easily overflow:https://github.com/tcbrindle/flux/blob/85b016eee0893b4971faaa3dbb415d308212a276/include/flux/op/cartesian_base.hpp#L219-L227
It should use
num::checked_mul()
instead to guard against UB.