ORNL / cpp-proposals-pub

Collaborating on papers for the ISO C++ committee - public repo
26 stars 27 forks source link

P2642: Avoid division by zero #442

Open mhoemmen opened 9 months ago

mhoemmen commented 9 months ago

Para 12.3 of the converting constructor from layout_stride::mapping explicitly divides by zero if the leftmost resp. rightmost extent is zero.

This a general issue with other constructors as well, e.g., if padding_value is zero.

The two-parameter constructor mapping(ext, pad) has a precondition that extents_type::index-cast(pad) is greater than zero. Thus, we already check in some cases. We should consider extending these checks to all the cases, so the mappings behave reasonably.

mhoemmen commented 9 months ago