I don't think that is a bug. From What is syntax highlighting and how does it work?
If there's more than one tag that has syntax highlighting, it uses a default and lets Prettify infer what's the best language to use.
That question has multiple tags with a language hint on it (scroll to the end of the wiki):
for-loop has no language hint.
This means Prettify falls back to the Default which is all possible keywords of major languages smashed together. I explained more in depth how that works here.
If you want proper highlighting add the explicit prettifier to use <!-- language: lang-cpp -->
or <!-- language: lang-c -->
above the relevant code blocks.
Or even better: Don't mix C and C++, ever.