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

Offen
#824 0 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@rak3-sh arbeitet bereits daran.

Seit 22.12.2024.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Beschreibung

Difficulty-Medium false positive/false negative Impact-Low
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.
Vorherrschende Sprache
CodeQL
Sterne
227
Forks
82
Ø Merge
6 T. 7 Std.
Gemergte PRs (30 T.)
9

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus github/codeql-coding-standards

Alle Issues in github/codeql-coding-standards

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.