Skip to content

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

@lcartey

Description

@lcartey
Collaborator

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();
};

Activity

added
Difficulty-LowA false positive or false negative report which is expected to take <1 day effort to address
false positive/false negativeAn issue related to observed false positives or false negatives.
on Jan 6, 2023
lcartey

lcartey commented on Jan 6, 2023

@lcartey
CollaboratorAuthor

See also:
#20
As it appears we do sometimes elide the copy/move constructors.

lcartey

lcartey commented on Mar 17, 2023

@lcartey
CollaboratorAuthor
self-assigned this
on Jan 14, 2024
lcartey

lcartey commented on Jan 20, 2025

@lcartey
CollaboratorAuthor

Adding a reference to these related changes:
#641

This eliminates unused compiler generated elided functions. However, because the user in the above case explicitly added the elided function, I believe that's why we still add a call in this case. We should confirm by creating a test case.

added
Difficulty-MediumA false positive or false negative report which is expected to take 1-5 days effort to address
and removed
Difficulty-LowA false positive or false negative report which is expected to take <1 day effort to address
on Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Difficulty-MediumA false positive or false negative report which is expected to take 1-5 days effort to addressImpact-HighStandard-AUTOSARfalse positive/false negativeAn issue related to observed false positives or false negatives.top-25-fpsuser-reportIssue reported by an end user of CodeQL Coding Standards

Type

No type

Projects

Status

Assigned

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @MichaelRFairhurst@lcartey@knewbury01

      Issue actions

        `A15-4-2`: Ignore elided calls when calculating the exception graph · Issue #158 · github/codeql-coding-standards