Problems with rule c:S5350

Hi there;

in my code I have lines like

volatile uint32_t* const pulSystimeS = (uint32_t* )0x12345678;

to get the value of an internal counter of my CPU. for this line sonar created the issue

*# Make the type of this variable a pointer-to-const. The current type of “pulSystimeS” is "volatile unsigned long const".

but I have no idea why, because the value is a volatile value which cannot be a constant. Is the an idea how I can solve this issue or is it a bug in the developer version of the C sensor?

I’m using the Developer Edition - Version 9.7.1 (build 62043) of SonarQube …

Best regards,
Ralf Ebert

1 Like

Hi Ralf,

Welcome to the community!

Your version is past EOL. Can you upgrade and see if this is still replicable? Your upgrade path is:

9.7.1 → 9.9 → 10.1 (last step optional)

You may find these resources helpful:

If you have questions about upgrading, feel free to open a new thread for that here.


Hi Ann,

meanwhile we have updated to v.9.9.1 but unfortunately the behavior hasn’t changed.

Is there anything else I can do to help to solve the problem?

Best regards,

Hi Ralf,

Thanks for confirming. I’ve flagged this for the language experts.


Hi @Ralf_Ebert ,
Indeed we have a false positive on this rule. I created a ticket to fix this.
Thanks for raising the issue!

Hi @Ralf_Ebert,

We took care of this ticket this week. However, today, we reached a different conclusion than last summer. Essentially, what you describe is the intended behavior of the rule.

When would I use const volatile, register volatile, static volatile in C++? gives this explanation:

Practical Usage [of const volatile]:

  • Accessing shared memory in read-only mode.
  • Accessing hardware registers in read-only mode.