Skip to content

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

Open
@lcartey

Description

@lcartey

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 addressImpact-HighStardard-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