`A15-4-2`: Ignore elided calls when calculating the exception graph

Open
#158 3 comments 0 reactions 1 assignee View on GitHub

@lcartey is already working on this.

Since Jan 14, 2024.

Assessment

This issue has not been assessed yet.

Description

Difficulty-Medium false positive/false negative Impact-High Standard-AUTOSAR top-25-fps user-report
Affected rules
  • A15-4-2
Description

Copy elision allows the compiler to omit copy and move construction in certain circumstances. Some of these circumstances are considered "mandatory" - i.e. the compiler must omit the explicit construction - and in those circumstances copy and move constructors may never be called.

If you have move/copy constructors which are never expected to be called because they are always elided, you may decide to throw an exception from the copy/move constructor to enforce that it is only used in circumstances where the elision occurs. As our call graph does not currently reflect the mandatory elision of functions, this can cause false positives.

Example
// `foo` is only used in circumstances where it is elided, so this exception is never thrown in practice
constexpr foo(const foo&) : dummy() {
  throw some_bad_exception();
};
Dominant language
CodeQL
Stars
227
Forks
82
Avg merge
6d 7h
Merged PRs (30d)
9

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.

More from github/codeql-coding-standards

All issues in github/codeql-coding-standards

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.