github / github/codeql

LGTM.com - false positive for C++ missing return statement

Offen
#4,105 3 Kommentare 0 Reaktionen 1 zugewiesene Person Beansprucht von @dbartol Auf GitHub ansehen
C++ false-positive
Vorherrschende Sprache
CodeQL
Sterne
10.1k
Forks
2.1k
Ø Merge
2 T. 15 Std.
Gemergte PRs (30 T.)
141

Beschreibung

**Description of the false positive**

Hi, there! I'm trying to add a fatal logging level to the logging infra. `LOG(FATAL)` will abort hence won't return. The macro is a wrapper around a stream-like class, whose destructor will call `abort()`, so after printing out the fatal error message, the program will be ternminated (refer to [this](https://github.com/iovisor/bpftrace/pull/1449/commits/89e940313767b4bcd475d535a788f1f1f825e39a) for more context). The destructor is marked with C++ attribute `[[noreturn]]`, which will make the compiler happy. I've also tried to suppress the alert with `// lgtm[cpp/missing-return]` but it won't work (remind me if I have done it in the wrong way). My guess is "missing return" is taken as an error so it won't be suppressed. But I'd think that since C++ provides the `[[noreturn]]` attribute to reassure the compiler, it should be considered an accepted behavior. Any thoughts on this?

**URL to the alert on the project page on LGTM.com**
https://lgtm.com/projects/g/iovisor/bpftrace/snapshot/0c6cc31868a95d11756df15ba2a4540058de15b0/files/src/attached_probe.cpp?sort=name&dir=ASC&mode=heatmap#x119f230625cb95f3:1

https://lgtm.com/projects/g/iovisor/bpftrace/snapshot/0c6cc31868a95d11756df15ba2a4540058de15b0/files/src/types.cpp?sort=name&dir=ASC&mode=heatmap#x65ffd3725acdcabb:1

https://lgtm.com/projects/g/iovisor/bpftrace/snapshot/0c6cc31868a95d11756df15ba2a4540058de15b0/files/src/ast/ast.cpp?sort=name&dir=ASC&mode=heatmap#x38807acfecd9b7d1:1

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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