MISRA 2008 C++ rule 16-2-5 is reported as a major bug but should not be


I have a C++ project being scanned using sonarcloud. I have a whole lot of issues being raised for rule:

Non-standard characters should not occur in header file names in “#include” directives

This is classified as a bug, and with major severity. I believe it should’nt be listed as a bug. And not of major severity, maybe more like Info or Minor.

An example C++ code sample that generates this issue is:

#include “dir\foo.h”

To fix it, I want to use a forward slash. Nonetheless our code builds, and works perfectly fine without this fix.

In our project there is no bug because of this issue. This is because our Windows OS env and compiler accepts the backward slash in file paths. Even if it were a problem, the code would not even build. The issue would be caught by the compiler before it even gets to the sonarcloud static analysis.

The issue’s reference source is MISRA C++ 2008 standard rule 16-2-5 (see http://www.tlemp.com/download/rule/MISRA-CPP-2008-STANDARD.pdf). They classify the rule as Advisory. Which means it should be followed but is not required. This reinforces that it is not a bug.


1 Like

Hello @SeanCae,

Thanks for the feedback. We will review the classification for this rule, and you can track our progress at [CPP-4031] - Jira.

If you wish, you can change the severity of this rule in your quality profile. It cannot, however, be customized to be a code smell.


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