# Issue with rule "Exceptions should not be thrown in "noexcept" functions" in c++

**URL:** <https://community.sonarsource.com/t/issue-with-rule-exceptions-should-not-be-thrown-in-noexcept-functions-in-c/48930>\
**Category:** SonarQube Cloud\
**Tags:** cfamily, sonarqube-cloud\
**Created:** [August 30, 2021, 12:44pm UTC](https://community.sonarsource.com/t/issue-with-rule-exceptions-should-not-be-thrown-in-noexcept-functions-in-c/48930 "2021-08-30T12:44:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Laurent](https://community.sonarsource.com/u/Laurent)\
**Post date:** [August 30, 2021, 12:44pm UTC](https://community.sonarsource.com/t/issue-with-rule-exceptions-should-not-be-thrown-in-noexcept-functions-in-c/48930/1 "2021-08-30T12:44:55Z")

</div>

We are using SonarCloud (so the last version) but the rule [RSPEC-3743](https://rules.sonarsource.com/cpp/RSPEC-3743) is not always working, and not detecting wrong “noexcept”

Here a very simple example where there is the warning on g2, but NOT on g1…  
BUT the two methods f1 and f2 are very similar

It seems to be a bug in the detection!

```auto
#include <filesystem>
#include <exception>

void f2(const std::string& _pathToFile)
{
    if (!_pathToFile.empty()) throw std::exception("bad");
}

void g2() noexcept
{
    f2("test");
}

void f1(const std::filesystem::path& _pathToFile)
{
    if (std::filesystem::exists(_pathToFile)) throw std::exception("bad");
}

void g1() noexcept
{
    f1("test");
}

```

---

<div class="post-metadata">

**Author:** ![Amelie](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/amelie/32/66942_2.png) [@Amelie](https://community.sonarsource.com/u/Amelie)\
**Post date:** [August 31, 2021, 9:55am UTC](https://community.sonarsource.com/t/issue-with-rule-exceptions-should-not-be-thrown-in-noexcept-functions-in-c/48930/2 "2021-08-31T09:55:29Z")

</div>

Hello @Laurent,

Thank you for reporting this!  
I was able to reproduce the false negative you mention, so I created a ticket ([CPP-3255](https://jira.sonarsource.com/browse/CPP-3255)) to fix that. You’re right, there seems to be a bug on our side.

Cheers,  
Amélie

---

<div class="post-metadata">

**Author:** ![Laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Laurent](https://community.sonarsource.com/u/Laurent)\
**Post date:** [September 2, 2021, 8:21am UTC](https://community.sonarsource.com/t/issue-with-rule-exceptions-should-not-be-thrown-in-noexcept-functions-in-c/48930/3 "2021-09-02T08:21:56Z")

</div>

I see the bug is resolved in 6.26 but trying to install the new build wrapper from [https://sonarcloud.io/static/cpp/build-wrapper-win-x86.zip](https://sonarcloud.io/static/cpp/build-wrapper-win-x86.zip) I still get the version 6.25…

When it will be available?  
Thanks

---

<div class="post-metadata">

**Author:** ![Amelie](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/amelie/32/66942_2.png) [@Amelie](https://community.sonarsource.com/u/Amelie)\
**Post date:** [September 2, 2021, 8:58am UTC](https://community.sonarsource.com/t/issue-with-rule-exceptions-should-not-be-thrown-in-noexcept-functions-in-c/48930/4 "2021-09-02T08:58:35Z")

</div>

The 6.26 version of the CFamily plugin will be available in SonarQube 9.1 that is planned to be released the 17th on September.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [September 9, 2021, 8:59am UTC](https://community.sonarsource.com/t/issue-with-rule-exceptions-should-not-be-thrown-in-noexcept-functions-in-c/48930/5 "2021-09-09T08:59:16Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
