ORNL / ORNL/cpp-proposals-pub

P2642: Avoid division by zero

Open
#442 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
29
Forks
26
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with paragraph 12.3 on the converting constructor from layout_stride::mapping, then compare the other mapping constructors, including mapping(ext, pad) and its existing precondition. Done means the constructors handle zero extents or padding without division by zero and apply consistent validity checks; no files or tests are named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.