Skip to content

A15-4-4: Conservatively assuming throwing behaviour for externally defined functions #424

Closed
@lcartey

Description

@lcartey

Affected rules

  • A15-4-4

Description

The exceptions library makes a conservative assumption about which functions will throw which exceptions. However, for this query that leads to false positives where an externally defined function is known to throw in certain circumstances, but this is not captured in the throw specification for the function.

Example

This function is erroneously identified as a candidate for noexcept even though append could throw an out_of_range error.

std::string concat(const std::string& s1, const std::string& s2) {
  std::string s3;
  s3.reserve(s1.size() +s2.size());
  s3.append(s1.c_str(), s1.size())
  s3.append(s2.c_str(), s2.size()));
  return s3;
}```

Metadata

Metadata

Assignees

Labels

Difficulty-LowA false positive or false negative report which is expected to take <1 day effort to addressImpact-Mediumfalse 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

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions