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

We are using SonarCloud (so the last version) but the rule 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!

#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");
}

Hello @Laurent,

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

Cheers,
Amélie

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 I still get the version 6.25…

When it will be available?
Thanks

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.

2 Likes

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