Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A15-4-4: Query incorrectly alerts functions that raise/can raise exceptions #824

Open
rak3-sh opened this issue Dec 17, 2024 · 0 comments
Open
Assignees
Labels
Difficulty-Medium A false positive or false negative report which is expected to take 1-5 days effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Low

Comments

@rak3-sh
Copy link
Contributor

rak3-sh commented Dec 17, 2024

Affected rules

A15-4-4

Description

  1. Query doesn’t consider ReThrowExpr. E.g. the query says to mark rethrow() below as noexcept

Example

template <bool DoRethrow>
void rethrow() {
  throw;
}

int main()
{
  rethrow<true>();
  return 0;
}
  1. The query doesn’t check for throw expressions that occur inside lambdas defined in a function. E.g.

Example

void func()  {
    std::call_once(init_flag_, [this] {
      if (sem_init(&sem_, 0, 0) != 0) {
        throw std::system_error(errno, std::system_category()); // Throw in a lambda.
      }
      initialized_ = true;
    });
  }
  1. In some cases the noexcept specification is a complex condition involving several logical operations or template instantiations. In such a case, CodeQL’s check for whether its noexcept(true) or noexcept explicitly false doesn’t work and it alerts that it can be marked as noexcept. For practical reasons, maybe we can consider a noexcept(expr) as being marked by the user as correct.
@rak3-sh rak3-sh added the false positive/false negative An issue related to observed false positives or false negatives. label Dec 17, 2024
rak3-sh added a commit to rak3-sh/codeql-coding-standards that referenced this issue Dec 17, 2024
@lcartey lcartey moved this from Reported to In Progress in Coding Standards Public Development Board Dec 22, 2024
@lcartey lcartey added Difficulty-Medium A false positive or false negative report which is expected to take 1-5 days effort to address Impact-Low labels Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty-Medium A false positive or false negative report which is expected to take 1-5 days effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Low
Projects
Development

No branches or pull requests

2 participants