codeql-coding-standards
codeql-coding-standards copied to clipboard
`A15-4-4`: Functions that allocate are considered non-throwing
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"));
}
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).