isocpp / isocpp/CppCoreGuidelines

Parameter pass-by-value heuristic: trivial copyability issue, and incomplete type issue

Open
#2,112 5 comments 4 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

F.16 says:

(Simple) ((Foundation)) Warn when a parameter being passed by value has a size greater than 2 * sizeof(void*). Suggest using a reference to const instead.
(Simple) ((Foundation)) Warn when a parameter passed by reference to const has a size less or equal than 2 * sizeof(void*). Suggest passing by value instead.

Two problems that have come up with this advice:

  • (easy) It should also say "and is trivially copyable"
  • (harder) When the parameter is of an incomplete user-defined type (class, enum, union) then we can't tell its size and trivial copyability

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 with guideline F.16 and review the two parameter pass-by-value recommendations quoted in the issue. Clarify how the advice should account for trivial copyability and incomplete user-defined types, then update the guideline wording so both cases are addressed. Done means the recommendations no longer overstate what can be determined for incomplete types.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.