Skip to content

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

Open
@hsutter

Description

@hsutter

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions