False positive for cpp:S1116

Version: 9.1 (build 47736)
The rule has an exception which I believe needs expanding: In the case of empty expanded macro and in the case of 2 consecutive semi-colons when one of the two is part of a macro-definition then the issue is not raised.

The code:

#include <iostream>

#define A_MACRO(string)\
  std::cout << "Here is a macro that says " string << std::endl;\

int main()
  A_MACRO("something interesting");
  return 0;

SonarQube raises the issue on the invocation of A_MACRO. The code uses a standard idiom for a multi-line macro, which places the code in the macro within curly braces. I believe the exception to the rule should be expanded to include this, as it would look strange to invoke the macro without a semicolon on the line.

Hi @obi ,
Thanks for reporting this point!
I created a ticket to follow up on this false positive.

Hello, @Fred_Tingaud ,
I’ve encountered the same issue in 9.3 for C - I assume any fix will impact both the C and CPP rules?

Thank you,

Hi @Adrianh,
Welcome to the community!
Yes, both C and C++ will be fixed at the same time.

Thank you for the quick reply! I will keep an eye out on that ticket, then.


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