You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<source>:1:6: warning: an exception may be thrown in function 'awoo' which should not throw exceptions [bugprone-exception-escape]
1 | void awoo() noexcept {
| ^
The text was updated successfully, but these errors were encountered:
https://godbolt.org/z/1sf8Gne35
```cpp
void awoo() noexcept {
[] { throw 0; };
}
```
This outputs
```
<source>:1:6: warning: an exception may be thrown in function 'awoo' which should not throw exceptions [bugprone-exception-escape]
1 | void awoo() noexcept {
| ^
```
I tried to reproduce the issue in a simplified clang-query request. Does anybody can explain why the simple matcher functionDecl(isNoThrow()) triggers on lambda like []() noexcept(false) { throw 0; }; ? While it doesn't trigger on a regular function with noexcept(false)
I tried to reproduce the issue in a simplified clang-query request. Does anybody can explain why the simple matcher functionDecl(isNoThrow()) triggers on lambda like []() noexcept(false) { throw 0; }; ? While it doesn't trigger on a regular function with noexcept(false)
In your example, only CXXConversionDecl and CXXDestructorDecl are matched as noexcept functions- https://godbolt.org/z/aefG99dYv. The main operator() with throw expression is not matched.
Your misunderstanding happens because ctor/dtor/operator() of lambda points to one location.
Note: code example in issue is only false-positive when lambda is not assigned to a variable.
voidawoo() noexcept { // no warning - lambda assigned to a variable and never called - GOODauto l = [] { throw0; };
}
voidawoo() noexcept { // warning - lambda is called - GOODauto l = [] { throw0; };
l();
}
voidawoo() noexcept { // warning - lambda is not assigned to a variable and never called - BAD
[] { throw0; };
}
https://godbolt.org/z/1sf8Gne35
This outputs
The text was updated successfully, but these errors were encountered: