Std::string in a struct leads to "Functional notation casts shall not be used."

We noticed some findings “Functional notation casts shall not be used.” in our code which we couldn’t explain. We initialize simple structs just as usual and for some it’s marked as an issue. So I reduced it to a very minimal sample:

struct Works
	uint32_t a;
	uint32_t b;
struct Fails
	std::string a;
	uint32_t b;
const auto testWorks = Works{0, 1};
const auto testFails = Fails{"test", 1};

As the names suggest the last line is marked as a functional notation case, the previous one is not. Why should that be a functional notation cast? I’d say it’s a false positive, isn’t it?

Used versions:
SonarQube Version 8.9.1 (build 44547)

Hello @max.sch,

Thanks for your report.

This was fixed in CFamily 6.26 which is part of SQ 9.1.

Updating to the latest SQ should fix the false positive

Hi @Abbas_Sabra,
That’s good to know. But it will not get integrated in 8.9 LTS?
Will talk to the admins if update to 9.1 is planned and/or possible for us.

@max.sch, no we don’t backport false-positive fixes to the LTS. I recommend updating when/if possible as we are continuously fixing false positives and improving the quality of the analysis.


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