cpp:EmptyCompoundStatement on blocks containing only ifdef statements

cpp

(Martin Quinson) #1

Hello,

I think that this issue is a false positive: https://sonarcloud.io/project/issues?createdAt=2019-01-20T04%3A36%3A50%2B0100&id=simgrid&open=AWhpYYR1_tDbB_jQe5vp

The code is as follows:

if (cond) {
  some code
} else {
 #if BOOST_VERSION < 105600
     this->fc_ = new boost::context::fcontext_t();
 #endif
}

The rule cpp:EmptyCompoundStatement gets triggered on the else branch, even if the block is not empty. I understand I could invert the else and #if lines to please sonar, but I think that this would not improve the readability of my code to mix if/else logic with the #ifdef one.

Thanks for this great tool that we use every day!
Mt


(Massimo Paladin) #2

Hi @mquinson,

thank you for your report, here is a ticket to address the issue you are facing: CPP-2074