Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[ub:expr.mul.div.by.zero] Code comment does not agree with normative wording

Open Beginner friendly
#9,341 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, tex
Domain
documentation

Research direction

Start at the [ub:expr.mul.div.by.zero] example and compare its comment with the normative wording in [expr.mul]/4 and the note in [expr.pre]/4. Correct the example so its statement about floating-point division by zero agrees with those passages, then check the linked wording for consistency.

Written by the indexing model from the issue text.

Description

ub-ifndr

[ub:expr.mul.div.by.zero]:

int main() {
  int x = 1 / 0;        // undefined behavior, division by zero
  double d = 1.0 / 0.0; // undefined behavior on systems where the range of
                        // representable values of double is [-max,+max], on systems where
                        // representable values is [-inf,+inf] this would not be undefined behavior
}

The normative wording is ([expr.mul]/4):

If the second operand of / or % is zero, the behavior is undefined ([ub:expr.mul.div.by.zero]).

That is, the behavior of 1.0 / 0.0 is undefined even on systems that have positive and negative infinity.

In addition, a note in [expr.pre]/4 (added by P3899R3 "Clarify the behavior of floating-point overflow") mentions:

If the operands are of a type that adheres to ISO/IEC 60559, division by zero is the only case where an arithmetic expression has undefined behavior ([expr.mul]).

Dominant language
TeX
Stars
221
Forks
813
Avg merge
17h 45m
Merged PRs (30d)
34

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.

More from cplusplus/draft

All issues in cplusplus/draft

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.