Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

DCL51-CPP: Only reserve function names when used within the global namespace #148

Open
Assignees
Labels
Difficulty-HighA false positive or false negative report which is expected to take 1+ week effort to address Impact-High Stardard-CERT-C++ false positive/false negativeAn issue related to observed false positives or false negatives. user-reportIssue reported by an end user of CodeQL Coding Standards
@lcartey

Description

Affected rules

  • DCL51-CPP

Description

The rule currently enforces that function names defined in standard library headers are not reused in any namespace. However, a careful re-reading of the C++ standard suggests that's overly specific. [reserved.names] specifically states that the only kinds of name that are reserved are macros, "global names" and "names with external linkage". In [extern.names], the standard says:

Each global function signature declared with external linkage in a header is reserved to the implementation to designate that function signature with external linkage.

So only global function signatures are reserved, and only where they have external linkage. I think we need to do the following:

  • Apply only to the global namespace
  • Filter list of reserved function names by those that appear in the global namespace and have external linkage (this may already be the case).
  • Match function signatures (I believe it is valid to reuse the name as long as the signature is different).

We may also need to review the rules for objects and _ prefixes.

Example

namespace MyNamespace {
 void all_of(); // COMPLIANT
}

Metadata

Metadata

Assignees

Labels

Difficulty-HighA false positive or false negative report which is expected to take 1+ week effort to address Impact-High Stardard-CERT-C++ false positive/false negativeAn issue related to observed false positives or false negatives. user-reportIssue reported by an end user of CodeQL Coding Standards

Type

No type

Projects

Status

In Progress

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /