isocpp / isocpp/CppCoreGuidelines

Remove enforcement rules of rule F.17

Open
#2,162 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
CSS
Stars
45.3k
Forks
5.6k
PR merge metrics
No merged PRs in 30d

Description

Rule F.17 (For “in-out” parameters, pass by reference to non-const) and Con.3 (By default, pass pointers and references to consts) have both two enforcement rules of which one of them is nearly identical:

  • F.17: Warn about functions regarding reference to non-const parameters that do not write to them
  • Con.3 Flag a function that does not modify an object passed by pointer or reference to non-const

This means that 2 rules will fire if a non-const reference parameter is not changed in the corresponding function body. Having 2 rules firing for the same situation is a coding standard design smell.

In order to solve this, I suggest to remove all enforcements from rule F.17 because the rule is about expresssing an intention, i.e. an in-out parameter. That is something you can't check automatically. To take this one step further, one might even consider to remove F.17 completely because we also have rule F.20 (For “out” output values, prefer return values to output parameters). Since F.20 describes some exceptions, removing F.17 might a bit too strong. So I suggest to remove the 2 enforcement rules of rule F.17.

Contributor guide

Open the contributing guide

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 by locating the F.17 and Con.3 guideline sections and comparing their enforcement rules. Remove both F.17 enforcement rules while preserving the guidance and the stated exceptions in F.20; check the surrounding document for consistent formatting and references.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.