codeql-coding-standards icon indicating copy to clipboard operation
codeql-coding-standards copied to clipboard

`A15-4-4`: Functions that allocate are considered non-throwing

Open gg-sr opened this issue 1 year ago • 1 comments

Affected rules

  • A15-4-4

Description

A15-4-4/MissingNoExcept.ql flags functions which are not noexcept when no exception is explicitly thrown by them (or the functions they call). Unfortunately, this doesn't take into a account the fact that std::bad_alloc can be implicitly thrown by functions which allocate.

Example

void AppendTo(std::string& string) {
  // rules/A15-4-4/MissingNoExcept.bqrs:
  //   Function AppendTo could be declared noexcept(true).
  static_cast<void>(string.append("foo"));
}

gg-sr avatar Aug 13 '24 01:08 gg-sr

Thanks for the report! This requires expanding our modelling of the exception behaviour of standard library functions, and deciding on default behaviour for different queries (ideally this one would over approximate the exceptions thrown, vs. the rules that look for missing annotations, which we may under approximate).

lcartey avatar Oct 23 '24 17:10 lcartey